Skip to content
DebugAllocatorDestroy

DebugAllocatorDestroy

Description

Tear down a DebugAllocator. Iterates the live map first and emits a LOG_ERROR for every still-live allocation, including its captured alloc trace.

Parameters

Name Direction Description
self in Handle returned by DebugAllocatorCreate*.
meta_alloc in Same allocator that was passed at create time.

Success

Function returns. The handle is invalid after this call; leak count is available via the live_at_destroy return prior to teardown if the caller called DebugAllocatorLiveCount first.

Failure

Function cannot fail.

Usage example (Cross-references)

Usage examples (Cross-references)
        ok = ok && DebugAllocatorOverflows(dbg) == 0;
    
        DebugAllocatorDestroy(dbg, ALLOCATOR_OF(&meta));
        HeapAllocatorDeinit(&meta);
        HeapAllocatorDeinit(&backing);
        bool ok = DebugAllocatorDoubleFrees(dbg) == 1;
    
        DebugAllocatorDestroy(dbg, ALLOCATOR_OF(&meta));
        HeapAllocatorDeinit(&meta);
        HeapAllocatorDeinit(&backing);
        bool ok = DebugAllocatorOverflows(dbg) == 1;
    
        DebugAllocatorDestroy(dbg, ALLOCATOR_OF(&meta));
        HeapAllocatorDeinit(&meta);
        HeapAllocatorDeinit(&backing);
        // parent and log the two leaks — but it tears down the tracking
        // map. Capture the count first.
        DebugAllocatorDestroy(dbg, ALLOCATOR_OF(&meta));
    
        // backing is HeapAllocator — it does not detect the leak itself;
    }
    
    void DebugAllocatorDestroy(DebugAllocator *self, Allocator *meta_alloc) {
        if (!self) {
            return;
Last updated on