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
signaturelock-open 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(...@@ -86,7 +86,7 @@ pub fn writeFilePath(
86 return result;86 return result;
87}87}
8888
89pub fn openCFile(allocator: *Allocator, file: fs.File, options: Options) !File.C {89fn openCFile(allocator: *Allocator, file: fs.File, options: Options) !File.C {
90 return File.C{90 return File.C{
91 .allocator = allocator,91 .allocator = allocator,
92 .file = file,92 .file = file,
...@@ -282,6 +282,8 @@ pub const File = struct {...@@ -282,6 +282,8 @@ pub const File = struct {
282 }282 }
283 }283 }
284 try writer.writeAll(self.main.items);284 try writer.writeAll(self.main.items);
285 self.file.?.close();
286 self.file = null;
285 }287 }
286 };288 };
287289
src-self-hosted/test.zig+2-3
...@@ -480,9 +480,8 @@ pub const TestContext = struct {...@@ -480,9 +480,8 @@ pub const TestContext = struct {
480 switch (update.case) {480 switch (update.case) {
481 .Transformation => |expected_output| {481 .Transformation => |expected_output| {
482 if (case.cbe) {482 if (case.cbe) {
483 var cfile: *link.File.C = module.bin_file.cast(link.File.C).?;483 // The C file is always closed after an update, because we don't support
484 cfile.file.?.close();484 // incremental updates
485 cfile.file = null;
486 var file = try tmp.dir.openFile(bin_name, .{ .read = true });485 var file = try tmp.dir.openFile(bin_name, .{ .read = true });
487 defer file.close();486 defer file.close();
488 var out = file.reader().readAllAlloc(allocator, 1024 * 1024) catch @panic("Unable to read C output!");487 var out = file.reader().readAllAlloc(allocator, 1024 * 1024) catch @panic("Unable to read C output!");