commit 061c1fd9abf61e5d7d1cf8cbb4aa24c1e4eadde0 (tree)
parent 4f709d224ae02c7875fbba31094f3cbc44f56807
Author: LeRoyce Pearson <leroycepearson@geemili.xyz>
Date: Fri, 6 Mar 2020 22:42:59 -0700
Use `readAllAlloc`
Now that the memory leak mentioned in #4656 has been fixed.
Diffstat:
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/lib/std/cache_hash.zig b/lib/std/cache_hash.zig
@@ -149,14 +149,9 @@ pub const CacheHash = struct {
self.manifest_file = try self.manifest_dir.createFile(manifest_file_path, .{ .read = true, .truncate = false });
}
- // create a buffer instead of using readAllAlloc
- // See: https://github.com/ziglang/zig/issues/4656
- var file_buffer = try Buffer.initCapacity(self.alloc, 16 * 1024);
- defer file_buffer.deinit();
-
// TODO: Figure out a good max value?
- try self.manifest_file.?.inStream().stream.readAllBuffer(&file_buffer, 16 * 1024);
- const file_contents = file_buffer.toSliceConst();
+ const file_contents = try self.manifest_file.?.inStream().stream.readAllAlloc(self.alloc, 16 * 1024);
+ defer self.alloc.free(file_contents);
const input_file_count = self.files.len;
var any_file_changed = false;