From 665f13b0cde4b9c2e69b139a87d272a67a9489e1 Mon Sep 17 00:00:00 2001 From: mlugg Date: Tue, 2 Sep 2025 18:47:31 +0100 Subject: SelfInfo deinit magic --- lib/std/debug/SelfInfo/DarwinModule.zig | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'lib/std/debug/SelfInfo/DarwinModule.zig') diff --git a/lib/std/debug/SelfInfo/DarwinModule.zig b/lib/std/debug/SelfInfo/DarwinModule.zig index d0cb47281f..976893e0af 100644 --- a/lib/std/debug/SelfInfo/DarwinModule.zig +++ b/lib/std/debug/SelfInfo/DarwinModule.zig @@ -578,9 +578,7 @@ fn unwindFrameMachO( return new_ip; } /// No cache needed, because `_dyld_get_image_header` etc are already fast. -pub const LookupCache = struct { - pub const init: LookupCache = .{}; -}; +pub const LookupCache = void; pub const DebugInfo = struct { unwind: ?struct { // Backed by the in-memory sections mapped by the loader @@ -601,22 +599,24 @@ pub const DebugInfo = struct { .full = null, }; + pub fn deinit(di: *DebugInfo, gpa: Allocator) void { + if (di.full) |*full| { + for (full.ofiles.values()) |*ofile| { + ofile.dwarf.deinit(gpa); + ofile.addr_table.deinit(gpa); + } + full.ofiles.deinit(gpa); + gpa.free(full.symbols); + posix.munmap(full.mapped_memory); + } + } + const OFile = struct { dwarf: Dwarf, // MLUGG TODO: this could use an adapter to just index straight into the strtab! addr_table: std.StringArrayHashMapUnmanaged(u64), }; - fn deinit(di: *DebugInfo, gpa: Allocator) void { - for (di.full.ofiles.values()) |*ofile| { - ofile.dwarf.deinit(gpa); - ofile.addr_table.deinit(gpa); - } - di.full.ofiles.deinit(); - gpa.free(di.full.symbols); - posix.munmap(di.full.mapped_memory); - } - fn loadOFile(gpa: Allocator, o_file_path: []const u8) !OFile { const mapped_mem = try mapDebugInfoFile(o_file_path); errdefer posix.munmap(mapped_mem); -- cgit v1.2.3