Commit 678e07b924
Changed files (6)
src
src/link/MachO/Archive.zig
@@ -88,6 +88,7 @@ const ar_hdr = extern struct {
};
pub fn deinit(self: *Archive, allocator: Allocator) void {
+ self.file.close();
for (self.toc.keys()) |*key| {
allocator.free(key.*);
}
src/link/MachO/DebugSymbols.zig
@@ -306,6 +306,7 @@ pub fn flushModule(self: *DebugSymbols, allocator: Allocator, options: link.Opti
}
pub fn deinit(self: *DebugSymbols, allocator: Allocator) void {
+ self.file.close();
self.segments.deinit(allocator);
self.sections.deinit(allocator);
self.dwarf.deinit();
src/link/Wasm/Archive.zig
@@ -95,6 +95,7 @@ const ar_hdr = extern struct {
};
pub fn deinit(archive: *Archive, allocator: Allocator) void {
+ archive.file.close();
for (archive.toc.keys()) |*key| {
allocator.free(key.*);
}
src/link/Wasm/Object.zig
@@ -141,6 +141,9 @@ pub fn create(gpa: Allocator, file: std.fs.File, name: []const u8, maybe_max_siz
/// Frees all memory of `Object` at once. The given `Allocator` must be
/// the same allocator that was used when `init` was called.
pub fn deinit(self: *Object, gpa: Allocator) void {
+ if (self.file) |file| {
+ file.close();
+ }
for (self.func_types) |func_ty| {
gpa.free(func_ty.params);
gpa.free(func_ty.returns);
src/link/MachO.zig
@@ -1437,7 +1437,6 @@ fn parseArchive(self: *MachO, path: []const u8, force_load: bool) !bool {
if (force_load) {
defer archive.deinit(gpa);
- defer file.close();
// Get all offsets from the ToC
var offsets = std.AutoArrayHashMap(u32, void).init(gpa);
defer offsets.deinit();
@@ -3015,7 +3014,6 @@ pub fn deinit(self: *MachO) void {
}
if (self.d_sym) |*d_sym| {
- d_sym.file.close();
d_sym.deinit(gpa);
}
@@ -3044,7 +3042,6 @@ pub fn deinit(self: *MachO) void {
self.objects.deinit(gpa);
for (self.archives.items) |*archive| {
- archive.file.close();
archive.deinit(gpa);
}
self.archives.deinit(gpa);
src/link/Wasm.zig
@@ -648,12 +648,10 @@ pub fn deinit(self: *Wasm) void {
gpa.free(segment_info.name);
}
for (self.objects.items) |*object| {
- object.file.?.close();
object.deinit(gpa);
}
for (self.archives.items) |*archive| {
- archive.file.close();
archive.deinit(gpa);
}