commit d8fa8b5455058d235793a8b9ecdf252fb8dd8782 (tree)
parent 3efdd7b2ad6cce5985d761240636b3d5eb3b4c84
Author: Andrew Kelley <andrew@ziglang.org>
Date: Tue, 29 Sep 2020 12:06:35 -0700
use Allocator.allocSentinel now that the stage1 bug is fixed
Thanks @LemonBoy!
Diffstat:
6 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/BRANCH_TODO b/BRANCH_TODO
@@ -1,3 +0,0 @@
- * wasi behavior tests failing
- * go ahead and use allocSentinel now that the stage1 bug is fixed
- * audit the base cache hash
diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig
@@ -231,8 +231,6 @@ fn AllocWithOptionsPayload(comptime Elem: type, comptime alignment: ?u29, compti
/// call `free` when done.
///
/// For allocating a single item, see `create`.
-///
-/// Deprecated; use `allocWithOptions`.
pub fn allocSentinel(
self: *Allocator,
comptime Elem: type,
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
@@ -1118,9 +1118,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
Compilation.dump_argv(argv.items);
}
- const new_argv_with_sentinel = try arena.alloc(?[*:0]const u8, argv.items.len + 1);
- new_argv_with_sentinel[argv.items.len] = null;
- const new_argv = new_argv_with_sentinel[0..argv.items.len :null];
+ const new_argv = try arena.allocSentinel(?[*:0]const u8, argv.items.len, null);
for (argv.items) |arg, i| {
new_argv[i] = try arena.dupeZ(u8, arg);
}
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
@@ -1589,10 +1589,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
}
// Oh, snapplesauce! We need null terminated argv.
- // TODO allocSentinel crashed stage1 so this is working around it.
- const new_argv_with_sentinel = try arena.alloc(?[*:0]const u8, argv.items.len + 1);
- new_argv_with_sentinel[argv.items.len] = null;
- const new_argv = new_argv_with_sentinel[0..argv.items.len: null];
+ const new_argv = try arena.allocSentinel(?[*:0]const u8, argv.items.len, null);
for (argv.items) |arg, i| {
new_argv[i] = try arena.dupeZ(u8, arg);
}
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
@@ -567,10 +567,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
Compilation.dump_argv(argv.items);
}
- // TODO allocSentinel crashed stage1 so this is working around it.
- const new_argv_with_sentinel = try arena.alloc(?[*:0]const u8, argv.items.len + 1);
- new_argv_with_sentinel[argv.items.len] = null;
- const new_argv = new_argv_with_sentinel[0..argv.items.len :null];
+ const new_argv = try arena.allocSentinel(?[*:0]const u8, argv.items.len, null);
for (argv.items) |arg, i| {
new_argv[i] = try arena.dupeZ(u8, arg);
}
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
@@ -385,10 +385,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
Compilation.dump_argv(argv.items);
}
- // TODO allocSentinel crashed stage1 so this is working around it.
- const new_argv_with_sentinel = try arena.alloc(?[*:0]const u8, argv.items.len + 1);
- new_argv_with_sentinel[argv.items.len] = null;
- const new_argv = new_argv_with_sentinel[0..argv.items.len :null];
+ const new_argv = try arena.allocSentinel(?[*:0]const u8, argv.items.len, null);
for (argv.items) |arg, i| {
new_argv[i] = try arena.dupeZ(u8, arg);
}