| ... | @@ -3279,71 +3279,77 @@ fn setEntryPoint(self: *MachO) !void { | ... | @@ -3279,71 +3279,77 @@ fn setEntryPoint(self: *MachO) !void { |
| 3279 | } | 3279 | } |
| 3280 | | 3280 | |
| 3281 | pub fn deinit(self: *MachO) void { | 3281 | pub fn deinit(self: *MachO) void { |
| | 3282 | const gpa = self.base.allocator; |
| | 3283 | |
| 3282 | if (build_options.have_llvm) { | 3284 | if (build_options.have_llvm) { |
| 3283 | if (self.llvm_object) |llvm_object| llvm_object.destroy(self.base.allocator); | 3285 | if (self.llvm_object) |llvm_object| llvm_object.destroy(gpa); |
| 3284 | } | 3286 | } |
| 3285 | | 3287 | |
| 3286 | if (self.d_sym) |*d_sym| { | 3288 | if (self.d_sym) |*d_sym| { |
| 3287 | d_sym.deinit(self.base.allocator); | 3289 | d_sym.deinit(gpa); |
| 3288 | } | 3290 | } |
| 3289 | | 3291 | |
| 3290 | self.section_ordinals.deinit(self.base.allocator); | 3292 | self.section_ordinals.deinit(gpa); |
| 3291 | self.tlv_ptr_entries.deinit(self.base.allocator); | 3293 | self.tlv_ptr_entries.deinit(gpa); |
| 3292 | self.tlv_ptr_entries_free_list.deinit(self.base.allocator); | 3294 | self.tlv_ptr_entries_free_list.deinit(gpa); |
| 3293 | self.tlv_ptr_entries_table.deinit(self.base.allocator); | 3295 | self.tlv_ptr_entries_table.deinit(gpa); |
| 3294 | self.got_entries.deinit(self.base.allocator); | 3296 | self.got_entries.deinit(gpa); |
| 3295 | self.got_entries_free_list.deinit(self.base.allocator); | 3297 | self.got_entries_free_list.deinit(gpa); |
| 3296 | self.got_entries_table.deinit(self.base.allocator); | 3298 | self.got_entries_table.deinit(gpa); |
| 3297 | self.stubs.deinit(self.base.allocator); | 3299 | self.stubs.deinit(gpa); |
| 3298 | self.stubs_free_list.deinit(self.base.allocator); | 3300 | self.stubs_free_list.deinit(gpa); |
| 3299 | self.stubs_table.deinit(self.base.allocator); | 3301 | self.stubs_table.deinit(gpa); |
| 3300 | self.strtab.deinit(self.base.allocator); | 3302 | self.strtab.deinit(gpa); |
| 3301 | self.globals.deinit(self.base.allocator); | 3303 | self.locals.deinit(gpa); |
| 3302 | self.locals.deinit(self.base.allocator); | 3304 | self.locals_free_list.deinit(gpa); |
| 3303 | self.locals_free_list.deinit(self.base.allocator); | 3305 | self.unresolved.deinit(gpa); |
| 3304 | self.unresolved.deinit(self.base.allocator); | 3306 | |
| | 3307 | for (self.globals.keys()) |key| { |
| | 3308 | gpa.free(key); |
| | 3309 | } |
| | 3310 | self.globals.deinit(gpa); |
| 3305 | | 3311 | |
| 3306 | for (self.objects.items) |*object| { | 3312 | for (self.objects.items) |*object| { |
| 3307 | object.deinit(self.base.allocator); | 3313 | object.deinit(gpa); |
| 3308 | } | 3314 | } |
| 3309 | self.objects.deinit(self.base.allocator); | 3315 | self.objects.deinit(gpa); |
| 3310 | | 3316 | |
| 3311 | for (self.archives.items) |*archive| { | 3317 | for (self.archives.items) |*archive| { |
| 3312 | archive.deinit(self.base.allocator); | 3318 | archive.deinit(gpa); |
| 3313 | } | 3319 | } |
| 3314 | self.archives.deinit(self.base.allocator); | 3320 | self.archives.deinit(gpa); |
| 3315 | | 3321 | |
| 3316 | for (self.dylibs.items) |*dylib| { | 3322 | for (self.dylibs.items) |*dylib| { |
| 3317 | dylib.deinit(self.base.allocator); | 3323 | dylib.deinit(gpa); |
| 3318 | } | 3324 | } |
| 3319 | self.dylibs.deinit(self.base.allocator); | 3325 | self.dylibs.deinit(gpa); |
| 3320 | self.dylibs_map.deinit(self.base.allocator); | 3326 | self.dylibs_map.deinit(gpa); |
| 3321 | self.referenced_dylibs.deinit(self.base.allocator); | 3327 | self.referenced_dylibs.deinit(gpa); |
| 3322 | | 3328 | |
| 3323 | for (self.load_commands.items) |*lc| { | 3329 | for (self.load_commands.items) |*lc| { |
| 3324 | lc.deinit(self.base.allocator); | 3330 | lc.deinit(gpa); |
| 3325 | } | 3331 | } |
| 3326 | self.load_commands.deinit(self.base.allocator); | 3332 | self.load_commands.deinit(gpa); |
| 3327 | | 3333 | |
| 3328 | for (self.managed_atoms.items) |atom| { | 3334 | for (self.managed_atoms.items) |atom| { |
| 3329 | atom.deinit(self.base.allocator); | 3335 | atom.deinit(gpa); |
| 3330 | self.base.allocator.destroy(atom); | 3336 | gpa.destroy(atom); |
| 3331 | } | 3337 | } |
| 3332 | self.managed_atoms.deinit(self.base.allocator); | 3338 | self.managed_atoms.deinit(gpa); |
| 3333 | self.atoms.deinit(self.base.allocator); | 3339 | self.atoms.deinit(gpa); |
| 3334 | { | 3340 | { |
| 3335 | var it = self.atom_free_lists.valueIterator(); | 3341 | var it = self.atom_free_lists.valueIterator(); |
| 3336 | while (it.next()) |free_list| { | 3342 | while (it.next()) |free_list| { |
| 3337 | free_list.deinit(self.base.allocator); | 3343 | free_list.deinit(gpa); |
| 3338 | } | 3344 | } |
| 3339 | self.atom_free_lists.deinit(self.base.allocator); | 3345 | self.atom_free_lists.deinit(gpa); |
| 3340 | } | 3346 | } |
| 3341 | if (self.base.options.module) |mod| { | 3347 | if (self.base.options.module) |mod| { |
| 3342 | for (self.decls.keys()) |decl_index| { | 3348 | for (self.decls.keys()) |decl_index| { |
| 3343 | const decl = mod.declPtr(decl_index); | 3349 | const decl = mod.declPtr(decl_index); |
| 3344 | decl.link.macho.deinit(self.base.allocator); | 3350 | decl.link.macho.deinit(gpa); |
| 3345 | } | 3351 | } |
| 3346 | self.decls.deinit(self.base.allocator); | 3352 | self.decls.deinit(gpa); |
| 3347 | } else { | 3353 | } else { |
| 3348 | assert(self.decls.count() == 0); | 3354 | assert(self.decls.count() == 0); |
| 3349 | } | 3355 | } |
| ... | @@ -3351,15 +3357,15 @@ pub fn deinit(self: *MachO) void { | ... | @@ -3351,15 +3357,15 @@ pub fn deinit(self: *MachO) void { |
| 3351 | { | 3357 | { |
| 3352 | var it = self.unnamed_const_atoms.valueIterator(); | 3358 | var it = self.unnamed_const_atoms.valueIterator(); |
| 3353 | while (it.next()) |atoms| { | 3359 | while (it.next()) |atoms| { |
| 3354 | atoms.deinit(self.base.allocator); | 3360 | atoms.deinit(gpa); |
| 3355 | } | 3361 | } |
| 3356 | self.unnamed_const_atoms.deinit(self.base.allocator); | 3362 | self.unnamed_const_atoms.deinit(gpa); |
| 3357 | } | 3363 | } |
| 3358 | | 3364 | |
| 3359 | self.atom_by_index_table.deinit(self.base.allocator); | 3365 | self.atom_by_index_table.deinit(gpa); |
| 3360 | | 3366 | |
| 3361 | if (self.code_signature) |*csig| { | 3367 | if (self.code_signature) |*csig| { |
| 3362 | csig.deinit(self.base.allocator); | 3368 | csig.deinit(gpa); |
| 3363 | } | 3369 | } |
| 3364 | } | 3370 | } |
| 3365 | | 3371 | |