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
36653665 } else {
36663666 const page_size = macho_file.page_size;
36673667 const sub_path = options.emit.?.sub_path;
3668 if (macho_file.base.file == null) {
3669 macho_file.base.file = try directory.handle.createFile(sub_path, .{
3670 .truncate = true,
3671 .read = true,
3672 .mode = link.determineMode(options.*),
3673 });
3674 }
3668
3669 const file = try directory.handle.createFile(sub_path, .{
3670 .truncate = true,
3671 .read = true,
3672 .mode = link.determineMode(options.*),
3673 });
3674 defer file.close();
3675
36753676 var zld = Zld{
36763677 .gpa = gpa,
3677 .file = macho_file.base.file.?,
3678 .file = file,
36783679 .page_size = macho_file.page_size,
36793680 .options = options,
36803681 };