authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-17 17:54:47+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-18 09:32:29+01:00
logee705e3ac71205142a4457acd2677f7be921d62b
tree8d956f5664e7550ef27822bc654de6e8eb80e110
parent76afdd0586dc646bee1f20fd9ff23c044d70a211

macho+zld: clean up opening and closing of file descriptors


1 files changed, 9 insertions(+), 8 deletions(-)

src/link/MachO/zld.zig+9-8
...@@ -3665,16 +3665,17 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr...@@ -3665,16 +3665,17 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr
3665 } else {3665 } else {
3666 const page_size = macho_file.page_size;3666 const page_size = macho_file.page_size;
3667 const sub_path = options.emit.?.sub_path;3667 const sub_path = options.emit.?.sub_path;
3668 if (macho_file.base.file == null) {3668
3669 macho_file.base.file = try directory.handle.createFile(sub_path, .{3669 const file = try directory.handle.createFile(sub_path, .{
3670 .truncate = true,3670 .truncate = true,
3671 .read = true,3671 .read = true,
3672 .mode = link.determineMode(options.*),3672 .mode = link.determineMode(options.*),
3673 });3673 });
3674 }3674 defer file.close();
3675
3675 var zld = Zld{3676 var zld = Zld{
3676 .gpa = gpa,3677 .gpa = gpa,
3677 .file = macho_file.base.file.?,3678 .file = file,
3678 .page_size = macho_file.page_size,3679 .page_size = macho_file.page_size,
3679 .options = options,3680 .options = options,
3680 };3681 };