Skip to content
MachoCacheDeinit

MachoCacheDeinit

Description

Release every cached Mach-O / DWARF table and the entries vector. Safe on a partially-initialised cache.

Success

Returns to the caller. self is zeroed.

Failure

Function cannot fail.

Usage example (Cross-references)

Usage examples (Cross-references)
    #    if FEATURE_PARSER_MACHO
        if (cache_ok)
            MachoCacheDeinit(&cache);
    #    endif
    }
    // ---------------------------------------------------------------------------
    
    void MachoCacheDeinit(MachoCache *self) {
        if (!self)
            return;
        ok                   = ok && name && ZstrCompare(name, "real_main_proc") == 0 && offset == 0x10;
    
        MachoCacheDeinit(&cache);
        DefaultAllocatorDeinit(&alloc);
        FileRemove(bin_path);
        ok                   = ok && name && ZstrCompare(name, "dsym_only_fn") == 0 && offset == 0x8;
    
        MachoCacheDeinit(&cache);
        DefaultAllocatorDeinit(&alloc);
        bool ok   = !MachoCacheResolve(&cache, bin_path, 0, 0x100000208ull, &name, NULL);
    
        MachoCacheDeinit(&cache);
        DefaultAllocatorDeinit(&alloc);
        ok = ok && DebugAllocatorLiveCount(&dbg) > baseline;
    
        MachoCacheDeinit(&cache);
        ok = ok && DebugAllocatorLiveCount(&dbg) == baseline;
        // baseline. A broken Deinit loop index (133 ++->--) underflows after
        // entry 0 and leaks entry 1.
        MachoCacheDeinit(&cache);
        ok = ok && DebugAllocatorLiveCount(&dbg) == baseline;
        ok                  = ok && DebugAllocatorLiveCount(&dbg) > baseline;
    
        MachoCacheDeinit(&cache);
        ok = ok && DebugAllocatorLiveCount(&dbg) == baseline;
        ok = ok && !MachoCacheResolve(&cache, bin_path, 0, 0x100000208ull, &name, NULL);
    
        MachoCacheDeinit(&cache);
        ok = ok && DebugAllocatorLiveCount(&dbg) == baseline;
        ok            = ok && DebugAllocatorLiveCount(&dbg) > baseline;
    
        MachoCacheDeinit(&cache);
        ok = ok && DebugAllocatorLiveCount(&dbg) == baseline;
        ok           = ok && name && ZstrCompare(name, "fn_at_zero") == 0 && off == 0;
    
        MachoCacheDeinit(&cache);
        FileRemove(bin_path);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&mod);
        MachoCacheDeinit(&cache);
        FileRemove(bin_path);
        DefaultAllocatorDeinit(&alloc);
        ok                  = ok && resolved && name && ZstrCompare(name, fn_name) == 0 && offset == 0x20;
    
        MachoCacheDeinit(&cache);
        FileRemove(bin_path);
        FileRemove(dsym_path);
        ok         = ok && VecLen(&cache.entries) == 1;
    
        MachoCacheDeinit(&cache);
        FileRemove(bin_path);
        FileRemove(dsym_path);
        ok                  = ok && DebugAllocatorLiveCount(&dbg) > baseline;
    
        MachoCacheDeinit(&cache);
        ok = ok && DebugAllocatorLiveCount(&dbg) == baseline;
Last updated on