Skip to content
DebugAllocatorInitWith

DebugAllocatorInitWith

Description

Construct a DebugAllocator with caller-supplied DebugAllocatorConfig. Use when you want to opt into force_page_backing or otherwise tune trace depth / canary width / freed-history retention away from the DEBUG_ALLOCATOR_DEFAULTS baseline. Captures the calling thread’s identifier at expansion so subsequent entry points can enforce the single-threaded contract.

_cfg is evaluated once.

Success

Returns a fully-initialised DebugAllocator value with the supplied config; the embedded heap / meta / page backing allocators are initialised but lazy (no OS calls yet); creator_tid is set to the calling thread.

Failure

Cannot fail at macro-expansion time.

Usage example (Cross-references)

Usage examples (Cross-references)
        DebugAllocatorConfig cfg = DEBUG_ALLOCATOR_DEFAULTS;
        cfg.track_freed_history  = false;
        DebugAllocator dbg       = DebugAllocatorInitWith(cfg);
        Allocator     *adbg      = ALLOCATOR_OF(&dbg);
        DebugAllocatorConfig cfg = DEBUG_ALLOCATOR_DEFAULTS;
        cfg.force_page_backing   = true;
        DebugAllocator dbg       = DebugAllocatorInitWith(cfg);
        Allocator     *adbg      = ALLOCATOR_OF(&dbg);
    /// TAGS: Allocator, Debug, Init
    ///
    #define DebugAllocatorInit() DebugAllocatorInitWith(DEBUG_ALLOCATOR_DEFAULTS)
    
    #endif // MISRA_STD_ALLOCATOR_DEBUG_H
    #    if FEATURE_DEFAULT_ALLOC_DEBUG_PAGE_BACKED
    #        define DefaultAllocatorInit()                                                                                 \
                DebugAllocatorInitWith(((DebugAllocatorConfig) {.capture_traces      = true,                               \
                                                                .detect_overflow     = true,                               \
                                                                .force_page_backing  = true,                               \
Last updated on