Use apge allocator again after it was fixed

This commit is contained in:
Alexandros Naskos 2020-06-29 02:03:51 +03:00
parent 0102963433
commit 6953ff95eb
2 changed files with 7 additions and 14 deletions

View File

@ -138,20 +138,16 @@ fn loadPackages(context: LoadPackagesContext) !void {
try std.fs.copyFileAbsolute(build_runner_path, target_path, .{});
defer std.fs.deleteFileAbsolute(target_path) catch {};
// TODO Using the page allocator directly here causes a segfault
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
const zig_run_result = try std.ChildProcess.exec(.{
.allocator = &arena.allocator,
.allocator = allocator,
.argv = &[_][]const u8{ zig_exe_path, "run", "build_runner.zig" },
.cwd = directory_path,
});
// TODO Add those back in when we stop using the arena
// defer {
// allocator.free(zig_run_result.stdout);
// allocator.free(zig_run_result.stderr);
// }
defer {
allocator.free(zig_run_result.stdout);
allocator.free(zig_run_result.stderr);
}
switch (zig_run_result.term) {
.Exited => |exit_code| {

View File

@ -1349,11 +1349,8 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config, ke
process.stdin.?.close();
process.stdin = null;
// TODO readAllAlloc degfaults with the page allocator
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
const stdout_bytes = try process.stdout.?.reader().readAllAlloc(&arena.allocator, std.math.maxInt(usize));
// defer allocator.free(stdout_bytes);
const stdout_bytes = try process.stdout.?.reader().readAllAlloc(allocator, std.math.maxInt(usize));
defer allocator.free(stdout_bytes);
switch (try process.wait()) {
.Exited => |code| if (code == 0) {