Skip to content

DebugRecord

Description

Per-allocation bookkeeping record. Stored in the embedded live / freed maps. Strings (none today) and stack frames live inline in the struct.

Usage example (Cross-references)

Usage examples (Cross-references)
            debug_write_canary((u8 *)user_p + bytes, canary);
    
        DebugRecord rec;
        MemSet(&rec, 0, sizeof(rec));
        rec.requested_size = bytes;
    }
    
    static void debug_record_free_trace(DebugAllocator *dbg, DebugRecord *rec) {
        if (dbg->config.capture_traces && dbg->config.trace_depth > 0) {
            u32 depth = dbg->config.trace_depth;
            return;
    
        DebugRecord *live_rec = MapGetFirstPtr(&dbg->live, ptr);
        if (!live_rec) {
            if (dbg->config.retain_metadata && dbg->freed_map_initialized) {
        if (!live_rec) {
            if (dbg->config.retain_metadata && dbg->freed_map_initialized) {
                DebugRecord *freed_rec = MapGetFirstPtr(&dbg->freed, ptr);
                if (freed_rec) {
                    dbg->double_frees += 1;
        }
    
        DebugRecord record = *live_rec;
        debug_record_free_trace(dbg, &record);
        dbg->bytes_in_use -= (u64)live_rec->requested_size;
            StackFrame alloc_trace[DEBUG_ALLOCATOR_MAX_TRACE];
            StackFrame free_trace[DEBUG_ALLOCATOR_MAX_TRACE];
        } DebugRecord;
    
        typedef Map(void *, DebugRecord) DebugRecordMap;
        } DebugRecord;
    
        typedef Map(void *, DebugRecord) DebugRecordMap;
    
        ///
Last updated on