macho: use preadAll to read in object files when emitting archive

This commit is contained in:
Jakub Konka 2024-02-07 23:25:15 +01:00
parent 114518c6b0
commit 272fc2df2e

View File

@ -1332,8 +1332,10 @@ pub fn writeAr(self: Object, ar_format: Archive.Format, macho_file: *MachO, writ
const file = macho_file.getFileHandle(self.file_handle);
// TODO try using copyRangeAll
const gpa = macho_file.base.comp.gpa;
const data = try file.readToEndAlloc(gpa, size);
const data = try gpa.alloc(u8, size);
defer gpa.free(data);
const amt = try file.preadAll(data, 0);
if (amt != size) return error.InputOutput;
try writer.writeAll(data);
}