Skip to content
AllocatorBytesRequested

AllocatorBytesRequested

Description

Read-only stats accessors. Each macro is a comma expression (((void)0, ...)) so the result is not an lvalue – assigning to AllocatorBytesInUse(a) = n fails at compile time. Mutation is the typed allocator’s job; readers stay observers.

a is any typed allocator pointer (HeapAllocator *, SlabAllocator *, …) or a plain Allocator *. ALLOCATOR_OF performs the typed -> base cast via _Generic without dispatching, so each accessor compiles down to a direct field load. No function call, no vtable.

Usage example (Cross-references)

Usage examples (Cross-references)
        bool  ok = (p1 != NULL) && (p2 != NULL);
        // bytes_requested is cumulative and does NOT decrease on free.
        ok = ok && (AllocatorBytesRequested(adbg) == 100);
    
        if (p1)
            AllocatorFree(adbg, p2);
        // still 100 after frees (cumulative)
        ok = ok && (AllocatorBytesRequested(adbg) == 100);
        DebugAllocatorDeinit(&dbg);
        return ok;
                  (AllocatorPeakBytesInUse(alloc) == outstanding) // 107 + 112
               && (AllocatorAllocations(alloc) == 0u)             // other counters zeroed
               && (AllocatorBytesRequested(alloc) == 0u);
    
        AllocatorFree(alloc, p);
Last updated on