authorgravatar for leroycepearson@geemili.xyzLeRoyce Pearson <leroycepearson@geemili.xyz> 2020-03-06 22:42:59-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-25 13:48:43-04:00
log061c1fd9abf61e5d7d1cf8cbb4aa24c1e4eadde0
tree7784171128a17fe3f2d8251024f4478b16be59cf
parent4f709d224ae02c7875fbba31094f3cbc44f56807

Use `readAllAlloc`

Now that the memory leak mentioned in #4656 has been fixed.

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

lib/std/cache_hash.zig+2-7
......@@ -149,14 +149,9 @@ pub const CacheHash = struct {
149149 self.manifest_file = try self.manifest_dir.createFile(manifest_file_path, .{ .read = true, .truncate = false });
150150 }
151151
152 // create a buffer instead of using readAllAlloc
153 // See: https://github.com/ziglang/zig/issues/4656
154 var file_buffer = try Buffer.initCapacity(self.alloc, 16 * 1024);
155 defer file_buffer.deinit();
156
157152 // TODO: Figure out a good max value?
158 try self.manifest_file.?.inStream().stream.readAllBuffer(&file_buffer, 16 * 1024);
159 const file_contents = file_buffer.toSliceConst();
153 const file_contents = try self.manifest_file.?.inStream().stream.readAllAlloc(self.alloc, 16 * 1024);
154 defer self.alloc.free(file_contents);
160155
161156 const input_file_count = self.files.len;
162157 var any_file_changed = false;