authorgravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-07-08 14:10:11-04:00
committergravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-07-08 14:10:11-04:00
logd060be880460598dcf89cb3d59bfcdf5059a923d
tree48ecf394632536d9525bdb4065d9d993e367ec6f
parent6b4863416611253c68539136ae9e4b83359efe74
signature Commit is signed but in an unrecognized format.

CBE: Don't expose openCFile, always close file after an update


2 files changed, 5 insertions(+), 4 deletions(-)

src-self-hosted/link.zig+3-1
......@@ -86,7 +86,7 @@ pub fn writeFilePath(
8686 return result;
8787}
8888
89pub fn openCFile(allocator: *Allocator, file: fs.File, options: Options) !File.C {
89fn openCFile(allocator: *Allocator, file: fs.File, options: Options) !File.C {
9090 return File.C{
9191 .allocator = allocator,
9292 .file = file,
......@@ -282,6 +282,8 @@ pub const File = struct {
282282 }
283283 }
284284 try writer.writeAll(self.main.items);
285 self.file.?.close();
286 self.file = null;
285287 }
286288 };
287289
src-self-hosted/test.zig+2-3
......@@ -480,9 +480,8 @@ pub const TestContext = struct {
480480 switch (update.case) {
481481 .Transformation => |expected_output| {
482482 if (case.cbe) {
483 var cfile: *link.File.C = module.bin_file.cast(link.File.C).?;
484 cfile.file.?.close();
485 cfile.file = null;
483 // The C file is always closed after an update, because we don't support
484 // incremental updates
486485 var file = try tmp.dir.openFile(bin_name, .{ .read = true });
487486 defer file.close();
488487 var out = file.reader().readAllAlloc(allocator, 1024 * 1024) catch @panic("Unable to read C output!");