Skip to content
DebugAllocatorFreedCount

DebugAllocatorFreedCount

Description

Number of entries currently held in the freed-history ring (only populated when track_freed_history is enabled in the DebugAllocator’s config). Each entry carries the original alloc + first-free stack traces used by the double-free diagnostic.

Parameters

Name Direction Description
self in DebugAllocator instance, or NULL.

Success

Returns the freed-history entry count.

Failure

Returns 0 when self is NULL, or when freed-history tracking is disabled.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    size DebugAllocatorFreedCount(const DebugAllocator *self) {
        if (!self)
            return 0;
        Allocator     *adbg = ALLOCATOR_OF(&dbg);
    
        bool  ok = (DebugAllocatorFreedCount(&dbg) == 0);
        void *p1 = AllocatorAlloc(adbg, 16, false);
        void *p2 = AllocatorAlloc(adbg, 32, false);
        void *p2 = AllocatorAlloc(adbg, 32, false);
        void *p3 = AllocatorAlloc(adbg, 64, false);
        ok       = ok && (DebugAllocatorFreedCount(&dbg) == 0); // alloc doesn't push
    
        AllocatorFree(adbg, p1);
    
        AllocatorFree(adbg, p1);
        ok = ok && (DebugAllocatorFreedCount(&dbg) == 1);
    
        AllocatorFree(adbg, p2);
        AllocatorFree(adbg, p2);
        AllocatorFree(adbg, p3);
        ok = ok && (DebugAllocatorFreedCount(&dbg) == 3);
    
        // intentional bypass: the freed-history Vec elements are internal
            AllocatorFree(adbg, p);
        }
        ok = ok && (DebugAllocatorFreedCount(&dbg) == 0);
        ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
Last updated on