Skip to content
DebugAllocatorReportLeaks

DebugAllocatorReportLeaks

Description

Append a human-readable leak report to out. For each entry in live, appends one summary line plus the captured alloc stack trace (formatted via FormatStackTrace when backtraces are enabled, otherwise raw instruction pointers).

Parameters

Name Direction Description
self in DebugAllocator instance, or NULL.
out in,out Str the report is appended to; pre-existing contents are preserved.

Success

Function returns. When live is non-empty, out has the report appended; when live is empty, out is left unchanged.

Failure

No action when self or out is NULL.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    void DebugAllocatorReportLeaks(DebugAllocator *self, Str *out) {
        if (!self || !out)
            return;
        HeapAllocator scratch = HeapAllocatorInit();
        Str           out     = StrInit(&scratch);
        DebugAllocatorReportLeaks(&dbg, &out);
    
        bool ok = StrLen(&out) > 0;
        HeapAllocator scratch = HeapAllocatorInit();
        Str           out     = StrInit(&scratch);
        DebugAllocatorReportLeaks(&dbg, &out);
    
        bool ok = (ZstrFindSubstring(StrBegin(&out), "leak:") != NULL);
        HeapAllocator scratch = HeapAllocatorInit();
        Str           out     = StrInit(&scratch);
        DebugAllocatorReportLeaks(&dbg, &out);
    
        ok = ok && (ZstrFindSubstring(StrBegin(&out), "leak:") != NULL);
        HeapAllocator scratch = HeapAllocatorInit();
        Str           out     = StrInit(&scratch);
        DebugAllocatorReportLeaks(&dbg, &out);
    
        // Build the out-of-range marker "#N " that only the `<=` mutant emits.
Last updated on