DebugAllocatorCreate
Description
Construct a DebugAllocator wrapping parent. Returns a pointer allocated through meta_alloc; the same meta_alloc must be passed back to DebugAllocatorDestroy so the handle and the internal maps can be released through the same allocator.
Parameters
| Name | Direction | Description |
|---|---|---|
parent |
in | Backing allocator to audit (user allocations flow through it). |
meta_alloc |
in | Allocator for the DebugAllocator’s own bookkeeping (live / freed maps, trace storage). Must outlive the returned DebugAllocator. |
Success
Returns a configured handle ready for use through ALLOCATOR_OF(handle) like any other allocator.
Failure
Returns NULL on allocation failure inside meta_alloc.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
AllocDebug.c:13:
HeapAllocator meta = HeapAllocatorInit();
DebugAllocator *dbg = DebugAllocatorCreate(ALLOCATOR_OF(&backing), ALLOCATOR_OF(&meta));
if (!dbg) {
return false;- In
AllocDebug.c:48:
HeapAllocator meta = HeapAllocatorInit();
DebugAllocator *dbg = DebugAllocatorCreate(ALLOCATOR_OF(&backing), ALLOCATOR_OF(&meta));
Allocator *adbg = ALLOCATOR_OF(dbg);- In
AllocDebug.c:69:
HeapAllocator meta = HeapAllocatorInit();
DebugAllocator *dbg = DebugAllocatorCreate(ALLOCATOR_OF(&backing), ALLOCATOR_OF(&meta));
Allocator *adbg = ALLOCATOR_OF(dbg);- In
AllocDebug.c:92:
HeapAllocator meta = HeapAllocatorInit();
DebugAllocator *dbg = DebugAllocatorCreate(ALLOCATOR_OF(&backing), ALLOCATOR_OF(&meta));
Allocator *adbg = ALLOCATOR_OF(dbg);- In
Debug.c:276:
DebugAllocator *DebugAllocatorCreateWith(Allocator *parent, Allocator *meta_alloc, DebugAllocatorConfig config) {
if (!parent || !meta_alloc) {
LOG_ERROR("DebugAllocatorCreate: parent and meta_alloc are required");
return NULL;
}- In
Debug.c:282:
DebugAllocator *dbg = (DebugAllocator *)AllocatorAlloc(meta_alloc, sizeof(DebugAllocator), true);
if (!dbg) {
LOG_ERROR("DebugAllocatorCreate: handle allocation failed");
return NULL;
}- In
Debug.c:314:
}
DebugAllocator *DebugAllocatorCreate(Allocator *parent, Allocator *meta_alloc) {
return DebugAllocatorCreateWith(parent, meta_alloc, DEBUG_ALLOCATOR_DEFAULTS);
}
Last updated on