authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-29 12:06:35-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-29 12:06:35-07:00
logd8fa8b5455058d235793a8b9ecdf252fb8dd8782
tree554f28740f2fae3c36e7ae507f850d55a026d455
parent3efdd7b2ad6cce5985d761240636b3d5eb3b4c84

use Allocator.allocSentinel now that the stage1 bug is fixed

Thanks @LemonBoy!

6 files changed, 4 insertions(+), 20 deletions(-)

BRANCH_TODO deleted-3
......@@ -1,3 +0,0 @@
1 * wasi behavior tests failing
2 * go ahead and use allocSentinel now that the stage1 bug is fixed
3 * audit the base cache hash
lib/std/mem/Allocator.zig-2
......@@ -231,8 +231,6 @@ fn AllocWithOptionsPayload(comptime Elem: type, comptime alignment: ?u29, compti
231231/// call `free` when done.
232232///
233233/// For allocating a single item, see `create`.
234///
235/// Deprecated; use `allocWithOptions`.
236234pub fn allocSentinel(
237235 self: *Allocator,
238236 comptime Elem: type,
src/link/Coff.zig+1-3
......@@ -1118,9 +1118,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
11181118 Compilation.dump_argv(argv.items);
11191119 }
11201120
1121 const new_argv_with_sentinel = try arena.alloc(?[*:0]const u8, argv.items.len + 1);
1122 new_argv_with_sentinel[argv.items.len] = null;
1123 const new_argv = new_argv_with_sentinel[0..argv.items.len :null];
1121 const new_argv = try arena.allocSentinel(?[*:0]const u8, argv.items.len, null);
11241122 for (argv.items) |arg, i| {
11251123 new_argv[i] = try arena.dupeZ(u8, arg);
11261124 }
src/link/Elf.zig+1-4
......@@ -1589,10 +1589,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
15891589 }
15901590
15911591 // Oh, snapplesauce! We need null terminated argv.
1592 // TODO allocSentinel crashed stage1 so this is working around it.
1593 const new_argv_with_sentinel = try arena.alloc(?[*:0]const u8, argv.items.len + 1);
1594 new_argv_with_sentinel[argv.items.len] = null;
1595 const new_argv = new_argv_with_sentinel[0..argv.items.len: null];
1592 const new_argv = try arena.allocSentinel(?[*:0]const u8, argv.items.len, null);
15961593 for (argv.items) |arg, i| {
15971594 new_argv[i] = try arena.dupeZ(u8, arg);
15981595 }
src/link/MachO.zig+1-4
......@@ -567,10 +567,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
567567 Compilation.dump_argv(argv.items);
568568 }
569569
570 // TODO allocSentinel crashed stage1 so this is working around it.
571 const new_argv_with_sentinel = try arena.alloc(?[*:0]const u8, argv.items.len + 1);
572 new_argv_with_sentinel[argv.items.len] = null;
573 const new_argv = new_argv_with_sentinel[0..argv.items.len :null];
570 const new_argv = try arena.allocSentinel(?[*:0]const u8, argv.items.len, null);
574571 for (argv.items) |arg, i| {
575572 new_argv[i] = try arena.dupeZ(u8, arg);
576573 }
src/link/Wasm.zig+1-4
......@@ -385,10 +385,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
385385 Compilation.dump_argv(argv.items);
386386 }
387387
388 // TODO allocSentinel crashed stage1 so this is working around it.
389 const new_argv_with_sentinel = try arena.alloc(?[*:0]const u8, argv.items.len + 1);
390 new_argv_with_sentinel[argv.items.len] = null;
391 const new_argv = new_argv_with_sentinel[0..argv.items.len :null];
388 const new_argv = try arena.allocSentinel(?[*:0]const u8, argv.items.len, null);
392389 for (argv.items) |arg, i| {
393390 new_argv[i] = try arena.dupeZ(u8, arg);
394391 }