Skip to content

Commit

Permalink
Use readAllAlloc
Browse files Browse the repository at this point in the history
Now that the memory leak mentioned in ziglang#4656 has been fixed.
  • Loading branch information
leroycep committed Apr 30, 2020
1 parent 2a04f31 commit 6435062
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/std/cache_hash.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6435062

Please sign in to comment.