Skip to content

Commit

Permalink
macho: do not store arena allocator in global scope
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Jan 27, 2024
1 parent a786dc8 commit a9ced4e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/MachO.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
base: Zld,
arena: std.heap.ArenaAllocator.State,
options: Options,

dyld_info_cmd: macho.dyld_info_command = .{},
Expand Down Expand Up @@ -103,7 +102,6 @@ fn createEmpty(gpa: Allocator, options: Options, thread_pool: *ThreadPool) !*Mac
.file = undefined,
.thread_pool = thread_pool,
},
.arena = std.heap.ArenaAllocator.init(gpa).state,
.options = options,
};
return self;
Expand Down Expand Up @@ -148,8 +146,6 @@ pub fn deinit(self: *MachO) void {
self.export_trie.deinit(gpa);
self.unwind_info.deinit(gpa);
self.unwind_records.deinit(gpa);

self.arena.promote(gpa).deinit();
}

pub fn flush(self: *MachO) !void {
Expand All @@ -169,8 +165,8 @@ pub fn flush(self: *MachO) !void {
try self.symbols.append(gpa, .{});
try self.symbols_extra.append(gpa, 0);

var arena_allocator = self.arena.promote(gpa);
defer self.arena = arena_allocator.state;
var arena_allocator = std.heap.ArenaAllocator.init(gpa);
defer arena_allocator.deinit();
const arena = arena_allocator.allocator();

const syslibroot = self.options.syslibroot;
Expand Down

0 comments on commit a9ced4e

Please sign in to comment.