authorgravatar for leroycepearson@geemili.xyzLeRoyce Pearson <leroycepearson@geemili.xyz> 2020-04-07 23:57:59-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-25 13:48:43-04:00
log204aa7dc1a183bb5fba91328d4f436c6f91471af
treee8a5e606b4a290f5bcc8958bb07d16943884df31
parentc88ece3679863cd55895bb9696d304c8d8754a4a

Remove unnecessary contents field from File

It was causing a segfault on `mipsel` architecture, not sure why other architectures weren't affected.

1 files changed, 2 insertions(+), 7 deletions(-)

lib/std/cache_hash.zig+2-7
...@@ -18,17 +18,12 @@ pub const File = struct {...@@ -18,17 +18,12 @@ pub const File = struct {
18 path: ?[]const u8,18 path: ?[]const u8,
19 stat: fs.File.Stat,19 stat: fs.File.Stat,
20 bin_digest: [BIN_DIGEST_LEN]u8,20 bin_digest: [BIN_DIGEST_LEN]u8,
21 contents: ?[]const u8,
2221
23 pub fn deinit(self: *@This(), alloc: *Allocator) void {22 pub fn deinit(self: *@This(), alloc: *Allocator) void {
24 if (self.path) |owned_slice| {23 if (self.path) |owned_slice| {
25 alloc.free(owned_slice);24 alloc.free(owned_slice);
26 self.path = null;25 self.path = null;
27 }26 }
28 if (self.contents) |owned_slice| {
29 alloc.free(owned_slice);
30 self.contents = null;
31 }
32 }27 }
33};28};
3429
...@@ -232,7 +227,7 @@ pub const CacheHash = struct {...@@ -232,7 +227,7 @@ pub const CacheHash = struct {
232 if (idx < input_file_count or idx == 0) {227 if (idx < input_file_count or idx == 0) {
233 self.manifest_dirty = true;228 self.manifest_dirty = true;
234 while (idx < input_file_count) : (idx += 1) {229 while (idx < input_file_count) : (idx += 1) {
235 var cache_hash_file = self.files.ptrAt(idx);230 var cache_hash_file = &self.files.items[idx];
236 self.populate_file_hash(cache_hash_file) catch |err| {231 self.populate_file_hash(cache_hash_file) catch |err| {
237 self.manifest_file.?.close();232 self.manifest_file.?.close();
238 self.manifest_file = null;233 self.manifest_file = null;
...@@ -318,7 +313,7 @@ fn hash_file(alloc: *Allocator, bin_digest: []u8, handle: *const fs.File) !void...@@ -318,7 +313,7 @@ fn hash_file(alloc: *Allocator, bin_digest: []u8, handle: *const fs.File) !void
318 blake3.final(bin_digest);313 blake3.final(bin_digest);
319}314}
320315
321test "cache file and the recall it" {316test "cache file and then recall it" {
322 const cwd = fs.cwd();317 const cwd = fs.cwd();
323318
324 const temp_file = "test.txt";319 const temp_file = "test.txt";