| author | |
| committer | |
| log | fcc0a5a913b586c56b3a9bb23f728d7bdd787b33 |
| tree | 0b31dcfff6e7341c32753e75b744c4ee6c74405d |
| parent | cd10ce9a67668bfdf1fd7ba57b499d93caa3c00f |
21 files changed, 29 insertions(+), 35 deletions(-)
build.zig+1-1| ... | @@ -308,7 +308,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -308,7 +308,7 @@ pub fn build(b: *std.Build) !void { |
| 308 | }, | 308 | }, |
| 309 | } | 309 | } |
| 310 | }; | 310 | }; |
| 311 | const version = try b.allocator.dupeZ(u8, version_slice); | 311 | const version = try b.allocator.dupeSentinel(u8, version_slice, 0); |
| 312 | exe_options.addOption([:0]const u8, "version", version); | 312 | exe_options.addOption([:0]const u8, "version", version); |
| 313 | 313 | ||
| 314 | if (enable_llvm) { | 314 | if (enable_llvm) { |
lib/compiler/aro/aro/CodeGen.zig+2-2| ... | @@ -894,7 +894,7 @@ fn genLval(c: *CodeGen, node_index: Node.Index) Error!Ir.Ref { | ... | @@ -894,7 +894,7 @@ fn genLval(c: *CodeGen, node_index: Node.Index) Error!Ir.Ref { |
| 894 | } | 894 | } |
| 895 | } | 895 | } |
| 896 | 896 | ||
| 897 | const duped_name = try c.builder.arena.allocator().dupeZ(u8, slice); | 897 | const duped_name = try c.builder.arena.allocator().dupeSentinel(u8, slice, 0); |
| 898 | const ref: Ir.Ref = @enumFromInt(c.builder.instructions.len); | 898 | const ref: Ir.Ref = @enumFromInt(c.builder.instructions.len); |
| 899 | try c.builder.instructions.append(c.builder.gpa, .{ .tag = .symbol, .data = .{ .label = duped_name }, .ty = .ptr }); | 899 | try c.builder.instructions.append(c.builder.gpa, .{ .tag = .symbol, .data = .{ .label = duped_name }, .ty = .ptr }); |
| 900 | return ref; | 900 | return ref; |
| ... | @@ -1112,7 +1112,7 @@ fn genCall(c: *CodeGen, call: Node.Call) Error!Ir.Ref { | ... | @@ -1112,7 +1112,7 @@ fn genCall(c: *CodeGen, call: Node.Call) Error!Ir.Ref { |
| 1112 | } | 1112 | } |
| 1113 | } | 1113 | } |
| 1114 | 1114 | ||
| 1115 | const duped_name = try c.builder.arena.allocator().dupeZ(u8, slice); | 1115 | const duped_name = try c.builder.arena.allocator().dupeSentinel(u8, slice, 0); |
| 1116 | const ref: Ir.Ref = @enumFromInt(c.builder.instructions.len); | 1116 | const ref: Ir.Ref = @enumFromInt(c.builder.instructions.len); |
| 1117 | try c.builder.instructions.append(c.builder.gpa, .{ .tag = .symbol, .data = .{ .label = duped_name }, .ty = .ptr }); | 1117 | try c.builder.instructions.append(c.builder.gpa, .{ .tag = .symbol, .data = .{ .label = duped_name }, .ty = .ptr }); |
| 1118 | break :blk ref; | 1118 | break :blk ref; |
lib/std/Build/Watch/FsEvents.zig+1-1| ... | @@ -195,7 +195,7 @@ pub fn setPaths(fse: *FsEvents, gpa: Allocator, steps: []const *std.Build.Step) | ... | @@ -195,7 +195,7 @@ pub fn setPaths(fse: *FsEvents, gpa: Allocator, steps: []const *std.Build.Step) |
| 195 | } else { | 195 | } else { |
| 196 | fse.watch_roots = try gpa.realloc(fse.watch_roots, need_dirs.count()); | 196 | fse.watch_roots = try gpa.realloc(fse.watch_roots, need_dirs.count()); |
| 197 | for (fse.watch_roots, need_dirs.keys()) |*out, in| { | 197 | for (fse.watch_roots, need_dirs.keys()) |*out, in| { |
| 198 | out.* = try paths_arena.dupeZ(u8, in); | 198 | out.* = try paths_arena.dupeSentinel(u8, in, 0); |
| 199 | } | 199 | } |
| 200 | } | 200 | } |
| 201 | if (enable_debug_logs) { | 201 | if (enable_debug_logs) { |
lib/std/Io/Dir.zig+2-2| ... | @@ -944,7 +944,7 @@ pub const RealPathFileAllocError = RealPathFileError || Allocator.Error; | ... | @@ -944,7 +944,7 @@ pub const RealPathFileAllocError = RealPathFileError || Allocator.Error; |
| 944 | pub fn realPathFileAlloc(dir: Dir, io: Io, sub_path: []const u8, allocator: Allocator) RealPathFileAllocError![:0]u8 { | 944 | pub fn realPathFileAlloc(dir: Dir, io: Io, sub_path: []const u8, allocator: Allocator) RealPathFileAllocError![:0]u8 { |
| 945 | var buffer: [max_path_bytes]u8 = undefined; | 945 | var buffer: [max_path_bytes]u8 = undefined; |
| 946 | const n = try realPathFile(dir, io, sub_path, &buffer); | 946 | const n = try realPathFile(dir, io, sub_path, &buffer); |
| 947 | return allocator.dupeZ(u8, buffer[0..n]); | 947 | return allocator.dupeSentinel(u8, buffer[0..n], 0); |
| 948 | } | 948 | } |
| 949 | 949 | ||
| 950 | /// Same as `realPathFile` except `absolute_path` is asserted to be an absolute | 950 | /// Same as `realPathFile` except `absolute_path` is asserted to be an absolute |
| ... | @@ -974,7 +974,7 @@ pub fn realPathFileAbsolute(io: Io, absolute_path: []const u8, out_buffer: []u8) | ... | @@ -974,7 +974,7 @@ pub fn realPathFileAbsolute(io: Io, absolute_path: []const u8, out_buffer: []u8) |
| 974 | pub fn realPathFileAbsoluteAlloc(io: Io, absolute_path: []const u8, allocator: Allocator) RealPathFileAllocError![:0]u8 { | 974 | pub fn realPathFileAbsoluteAlloc(io: Io, absolute_path: []const u8, allocator: Allocator) RealPathFileAllocError![:0]u8 { |
| 975 | var buffer: [max_path_bytes]u8 = undefined; | 975 | var buffer: [max_path_bytes]u8 = undefined; |
| 976 | const n = try realPathFileAbsolute(io, absolute_path, &buffer); | 976 | const n = try realPathFileAbsolute(io, absolute_path, &buffer); |
| 977 | return allocator.dupeZ(u8, buffer[0..n]); | 977 | return allocator.dupeSentinel(u8, buffer[0..n], 0); |
| 978 | } | 978 | } |
| 979 | 979 | ||
| 980 | pub const DeleteFileError = error{ | 980 | pub const DeleteFileError = error{ |
lib/std/Io/Dispatch.zig+2-2| ... | @@ -4086,7 +4086,7 @@ fn processReplace(userdata: ?*anyopaque, options: process.ReplaceOptions) proces | ... | @@ -4086,7 +4086,7 @@ fn processReplace(userdata: ?*anyopaque, options: process.ReplaceOptions) proces |
| 4086 | const arena = arena_allocator.allocator(); | 4086 | const arena = arena_allocator.allocator(); |
| 4087 | 4087 | ||
| 4088 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); | 4088 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); |
| 4089 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr; | 4089 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeSentinel(u8, arg, 0)).ptr; |
| 4090 | 4090 | ||
| 4091 | const env_block = env_block: { | 4091 | const env_block = env_block: { |
| 4092 | const prog_fd: i32 = -1; | 4092 | const prog_fd: i32 = -1; |
| ... | @@ -4222,7 +4222,7 @@ fn spawn(ev: *Evented, options: process.SpawnOptions) process.SpawnError!Spawned | ... | @@ -4222,7 +4222,7 @@ fn spawn(ev: *Evented, options: process.SpawnOptions) process.SpawnError!Spawned |
| 4222 | // Therefore, we do all the allocation for the execve() before the fork(). | 4222 | // Therefore, we do all the allocation for the execve() before the fork(). |
| 4223 | // This means we must do the null-termination of argv and env vars here. | 4223 | // This means we must do the null-termination of argv and env vars here. |
| 4224 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); | 4224 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); |
| 4225 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr; | 4225 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeSentinel(u8, arg, 0)).ptr; |
| 4226 | 4226 | ||
| 4227 | const env_block = env_block: { | 4227 | const env_block = env_block: { |
| 4228 | const prog_fd: i32 = if (prog_pipe[1] == -1) -1 else prog_fileno; | 4228 | const prog_fd: i32 = if (prog_pipe[1] == -1) -1 else prog_fileno; |
lib/std/Io/Threaded.zig+2-2| ... | @@ -14954,7 +14954,7 @@ fn processReplace(userdata: ?*anyopaque, options: process.ReplaceOptions) proces | ... | @@ -14954,7 +14954,7 @@ fn processReplace(userdata: ?*anyopaque, options: process.ReplaceOptions) proces |
| 14954 | const arena = arena_allocator.allocator(); | 14954 | const arena = arena_allocator.allocator(); |
| 14955 | 14955 | ||
| 14956 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); | 14956 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); |
| 14957 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr; | 14957 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeSentinel(u8, arg, 0)).ptr; |
| 14958 | 14958 | ||
| 14959 | const env_block = env_block: { | 14959 | const env_block = env_block: { |
| 14960 | const prog_fd: i32 = -1; | 14960 | const prog_fd: i32 = -1; |
| ... | @@ -15061,7 +15061,7 @@ fn spawnPosix(t: *Threaded, options: process.SpawnOptions) process.SpawnError!Sp | ... | @@ -15061,7 +15061,7 @@ fn spawnPosix(t: *Threaded, options: process.SpawnOptions) process.SpawnError!Sp |
| 15061 | // Therefore, we do all the allocation for the execve() before the fork(). | 15061 | // Therefore, we do all the allocation for the execve() before the fork(). |
| 15062 | // This means we must do the null-termination of argv and env vars here. | 15062 | // This means we must do the null-termination of argv and env vars here. |
| 15063 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); | 15063 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); |
| 15064 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr; | 15064 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeSentinel(u8, arg, 0)).ptr; |
| 15065 | 15065 | ||
| 15066 | const prog_fileno = 3; | 15066 | const prog_fileno = 3; |
| 15067 | comptime assert(@max(posix.STDIN_FILENO, posix.STDOUT_FILENO, posix.STDERR_FILENO) + 1 == prog_fileno); | 15067 | comptime assert(@max(posix.STDIN_FILENO, posix.STDOUT_FILENO, posix.STDERR_FILENO) + 1 == prog_fileno); |
lib/std/Io/Uring.zig+2-2| ... | @@ -4226,7 +4226,7 @@ fn processReplace(userdata: ?*anyopaque, options: process.ReplaceOptions) proces | ... | @@ -4226,7 +4226,7 @@ fn processReplace(userdata: ?*anyopaque, options: process.ReplaceOptions) proces |
| 4226 | const arena = arena_allocator.allocator(); | 4226 | const arena = arena_allocator.allocator(); |
| 4227 | 4227 | ||
| 4228 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); | 4228 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); |
| 4229 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr; | 4229 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeSentinel(u8, arg, 0)).ptr; |
| 4230 | 4230 | ||
| 4231 | const env_block = env_block: { | 4231 | const env_block = env_block: { |
| 4232 | const prog_fd: i32 = -1; | 4232 | const prog_fd: i32 = -1; |
| ... | @@ -4369,7 +4369,7 @@ fn spawn(ev: *Evented, options: process.SpawnOptions) process.SpawnError!Spawned | ... | @@ -4369,7 +4369,7 @@ fn spawn(ev: *Evented, options: process.SpawnOptions) process.SpawnError!Spawned |
| 4369 | // Therefore, we do all the allocation for the execve() before the fork(). | 4369 | // Therefore, we do all the allocation for the execve() before the fork(). |
| 4370 | // This means we must do the null-termination of argv and env vars here. | 4370 | // This means we must do the null-termination of argv and env vars here. |
| 4371 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); | 4371 | const argv_buf = try arena.allocSentinel(?[*:0]const u8, options.argv.len, null); |
| 4372 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr; | 4372 | for (options.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeSentinel(u8, arg, 0)).ptr; |
| 4373 | 4373 | ||
| 4374 | const env_block = env_block: { | 4374 | const env_block = env_block: { |
| 4375 | const prog_fd: i32 = if (prog_pipe[1] == -1) -1 else prog_fileno; | 4375 | const prog_fd: i32 = if (prog_pipe[1] == -1) -1 else prog_fileno; |
lib/std/debug.zig+1-1| ... | @@ -517,7 +517,7 @@ pub fn defaultPanic(msg: []const u8, first_trace_addr: ?usize) noreturn { | ... | @@ -517,7 +517,7 @@ pub fn defaultPanic(msg: []const u8, first_trace_addr: ?usize) noreturn { |
| 517 | 517 | ||
| 518 | if (uefi.system_table.boot_services) |bs| { | 518 | if (uefi.system_table.boot_services) |bs| { |
| 519 | // ExitData buffer must be allocated using boot_services.allocatePool (spec: page 220) | 519 | // ExitData buffer must be allocated using boot_services.allocatePool (spec: page 220) |
| 520 | const exit_data = uefi.raw_pool_allocator.dupeZ(u16, exit_msg) catch @trap(); | 520 | const exit_data = uefi.raw_pool_allocator.dupeSentinel(u16, exit_msg, 0) catch @trap(); |
| 521 | bs.exit(uefi.handle, .aborted, exit_data) catch {}; | 521 | bs.exit(uefi.handle, .aborted, exit_data) catch {}; |
| 522 | } | 522 | } |
| 523 | @trap(); | 523 | @trap(); |
lib/std/fs/test.zig+2-2| ... | @@ -135,7 +135,7 @@ const TestContext = struct { | ... | @@ -135,7 +135,7 @@ const TestContext = struct { |
| 135 | const allocator = self.arena.allocator(); | 135 | const allocator = self.arena.allocator(); |
| 136 | const transformed_path = try self.transform_fn(allocator, self.io, self.dir, relative_path); | 136 | const transformed_path = try self.transform_fn(allocator, self.io, self.dir, relative_path); |
| 137 | if (native_os == .windows) { | 137 | if (native_os == .windows) { |
| 138 | const transformed_sep_path = try allocator.dupeZ(u8, transformed_path); | 138 | const transformed_sep_path = try allocator.dupeSentinel(u8, transformed_path, 0); |
| 139 | std.mem.replaceScalar(u8, transformed_sep_path, switch (self.path_sep) { | 139 | std.mem.replaceScalar(u8, transformed_sep_path, switch (self.path_sep) { |
| 140 | '/' => '\\', | 140 | '/' => '\\', |
| 141 | '\\' => '/', | 141 | '\\' => '/', |
| ... | @@ -153,7 +153,7 @@ const TestContext = struct { | ... | @@ -153,7 +153,7 @@ const TestContext = struct { |
| 153 | pub fn toCanonicalPathSep(self: *TestContext, path: [:0]const u8) ![:0]const u8 { | 153 | pub fn toCanonicalPathSep(self: *TestContext, path: [:0]const u8) ![:0]const u8 { |
| 154 | if (native_os == .windows) { | 154 | if (native_os == .windows) { |
| 155 | const allocator = self.arena.allocator(); | 155 | const allocator = self.arena.allocator(); |
| 156 | const transformed_sep_path = try allocator.dupeZ(u8, path); | 156 | const transformed_sep_path = try allocator.dupeSentinel(u8, path, 0); |
| 157 | std.mem.replaceScalar(u8, transformed_sep_path, '/', '\\'); | 157 | std.mem.replaceScalar(u8, transformed_sep_path, '/', '\\'); |
| 158 | return transformed_sep_path; | 158 | return transformed_sep_path; |
| 159 | } | 159 | } |
lib/std/mem.zig+1-1| ... | @@ -4964,7 +4964,7 @@ test isAligned { | ... | @@ -4964,7 +4964,7 @@ test isAligned { |
| 4964 | } | 4964 | } |
| 4965 | 4965 | ||
| 4966 | test "freeing empty string with null-terminated sentinel" { | 4966 | test "freeing empty string with null-terminated sentinel" { |
| 4967 | const empty_string = try testing.allocator.dupeZ(u8, ""); | 4967 | const empty_string = try testing.allocator.dupeSentinel(u8, "", 0); |
| 4968 | testing.allocator.free(empty_string); | 4968 | testing.allocator.free(empty_string); |
| 4969 | } | 4969 | } |
| 4970 | 4970 |
lib/std/mem/Allocator.zig-6| ... | @@ -456,12 +456,6 @@ pub fn dupe(allocator: Allocator, comptime T: type, m: []const T) Error![]T { | ... | @@ -456,12 +456,6 @@ pub fn dupe(allocator: Allocator, comptime T: type, m: []const T) Error![]T { |
| 456 | return new_buf; | 456 | return new_buf; |
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | /// Deprecated in favor of `dupeSentinel` | ||
| 460 | /// Copies `m` to newly allocated memory, with a null-terminated element. Caller owns the memory. | ||
| 461 | pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) Error![:0]T { | ||
| 462 | return allocator.dupeSentinel(T, m, 0); | ||
| 463 | } | ||
| 464 | |||
| 465 | /// Copies `m` to newly allocated memory, with a null-terminated element. Caller owns the memory. | 459 | /// Copies `m` to newly allocated memory, with a null-terminated element. Caller owns the memory. |
| 466 | pub fn dupeSentinel( | 460 | pub fn dupeSentinel( |
| 467 | allocator: Allocator, | 461 | allocator: Allocator, |
lib/std/os/plan9.zig+1-1| ... | @@ -299,7 +299,7 @@ pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, _: mode_t) usize { | ... | @@ -299,7 +299,7 @@ pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, _: mode_t) usize { |
| 299 | const dir_path = std.mem.span(@as([*:0]u8, @ptrCast(&dir_path_buf))); | 299 | const dir_path = std.mem.span(@as([*:0]u8, @ptrCast(&dir_path_buf))); |
| 300 | const total_path = std.fs.path.join(alloc, &.{ dir_path, std.mem.span(path) }) catch unreachable; // the allocation shouldn't fail because it should not exceed max_path_bytes | 300 | const total_path = std.fs.path.join(alloc, &.{ dir_path, std.mem.span(path) }) catch unreachable; // the allocation shouldn't fail because it should not exceed max_path_bytes |
| 301 | fba.reset(); | 301 | fba.reset(); |
| 302 | const total_path_z = alloc.dupeZ(u8, total_path) catch unreachable; // should not exceed max_path_bytes + 1 | 302 | const total_path_z = alloc.dupeSentinel(u8, total_path, 0) catch unreachable; // should not exceed max_path_bytes + 1 |
| 303 | return open(total_path_z.ptr, flags); | 303 | return open(total_path_z.ptr, flags); |
| 304 | } | 304 | } |
| 305 | 305 |
lib/std/process.zig+2-2| ... | @@ -85,7 +85,7 @@ pub fn currentPathAlloc(io: Io, allocator: Allocator) CurrentPathAllocError![:0] | ... | @@ -85,7 +85,7 @@ pub fn currentPathAlloc(io: Io, allocator: Allocator) CurrentPathAllocError![:0] |
| 85 | error.NameTooLong => unreachable, | 85 | error.NameTooLong => unreachable, |
| 86 | else => |e| return e, | 86 | else => |e| return e, |
| 87 | }; | 87 | }; |
| 88 | return allocator.dupeZ(u8, buffer[0..n]); | 88 | return allocator.dupeSentinel(u8, buffer[0..n], 0); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | test currentPathAlloc { | 91 | test currentPathAlloc { |
| ... | @@ -734,7 +734,7 @@ pub fn executablePathAlloc(io: Io, allocator: Allocator) ExecutablePathAllocErro | ... | @@ -734,7 +734,7 @@ pub fn executablePathAlloc(io: Io, allocator: Allocator) ExecutablePathAllocErro |
| 734 | error.NameTooLong => unreachable, | 734 | error.NameTooLong => unreachable, |
| 735 | else => |e| return e, | 735 | else => |e| return e, |
| 736 | }; | 736 | }; |
| 737 | return allocator.dupeZ(u8, buffer[0..n]); | 737 | return allocator.dupeSentinel(u8, buffer[0..n], 0); |
| 738 | } | 738 | } |
| 739 | 739 | ||
| 740 | pub const ExecutablePathError = ExecutablePathBaseError || error{NameTooLong}; | 740 | pub const ExecutablePathError = ExecutablePathBaseError || error{NameTooLong}; |
lib/std/process/Environ.zig+1-1| ... | @@ -754,7 +754,7 @@ pub fn createPosixBlock( | ... | @@ -754,7 +754,7 @@ pub fn createPosixBlock( |
| 754 | }, | 754 | }, |
| 755 | .nothing => {}, | 755 | .nothing => {}, |
| 756 | }; | 756 | }; |
| 757 | envp[envp_len] = try gpa.dupeZ(u8, mem.span(entry)); | 757 | envp[envp_len] = try gpa.dupeSentinel(u8, mem.span(entry), 0); |
| 758 | envp_len += 1; | 758 | envp_len += 1; |
| 759 | } | 759 | } |
| 760 | 760 |
lib/std/zig/LibCInstallation.zig+1-1| ... | @@ -70,7 +70,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const | ... | @@ -70,7 +70,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const |
| 70 | if (value.len == 0) { | 70 | if (value.len == 0) { |
| 71 | @field(self, field.name) = null; | 71 | @field(self, field.name) = null; |
| 72 | } else { | 72 | } else { |
| 73 | found_keys[i].allocated = try allocator.dupeZ(u8, value); | 73 | found_keys[i].allocated = try allocator.dupeSentinel(u8, value, 0); |
| 74 | @field(self, field.name) = found_keys[i].allocated; | 74 | @field(self, field.name) = found_keys[i].allocated; |
| 75 | } | 75 | } |
| 76 | break; | 76 | break; |
src/Compilation.zig+1-1| ... | @@ -1869,7 +1869,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, | ... | @@ -1869,7 +1869,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 1869 | const comp: *Compilation = comp: { | 1869 | const comp: *Compilation = comp: { |
| 1870 | // We put the `Compilation` itself in the arena. Freeing the arena will free the module. | 1870 | // We put the `Compilation` itself in the arena. Freeing the arena will free the module. |
| 1871 | // It's initialized later after we prepare the initialization options. | 1871 | // It's initialized later after we prepare the initialization options. |
| 1872 | const root_name = try arena.dupeZ(u8, options.root_name); | 1872 | const root_name = try arena.dupeSentinel(u8, options.root_name, 0); |
| 1873 | 1873 | ||
| 1874 | // The "any" values provided by resolved config only account for | 1874 | // The "any" values provided by resolved config only account for |
| 1875 | // explicitly-provided settings. We now make them additionally account | 1875 | // explicitly-provided settings. We now make them additionally account |
src/codegen/llvm.zig+1-1| ... | @@ -918,7 +918,7 @@ pub const Object = struct { | ... | @@ -918,7 +918,7 @@ pub const Object = struct { |
| 918 | } | 918 | } |
| 919 | 919 | ||
| 920 | const target_triple_sentinel = | 920 | const target_triple_sentinel = |
| 921 | try o.gpa.dupeZ(u8, o.builder.target_triple.slice(&o.builder).?); | 921 | try o.gpa.dupeSentinel(u8, o.builder.target_triple.slice(&o.builder).?, 0); |
| 922 | defer o.gpa.free(target_triple_sentinel); | 922 | defer o.gpa.free(target_triple_sentinel); |
| 923 | 923 | ||
| 924 | const emit_asm_msg = options.asm_path orelse "(none)"; | 924 | const emit_asm_msg = options.asm_path orelse "(none)"; |
src/link/Lld.zig+2-2| ... | @@ -287,7 +287,7 @@ fn linkAsArchive(lld: *Lld, arena: Allocator) !void { | ... | @@ -287,7 +287,7 @@ fn linkAsArchive(lld: *Lld, arena: Allocator) !void { |
| 287 | const comp = base.comp; | 287 | const comp = base.comp; |
| 288 | const directory = base.emit.root_dir; // Just an alias to make it shorter to type. | 288 | const directory = base.emit.root_dir; // Just an alias to make it shorter to type. |
| 289 | const full_out_path = try directory.join(arena, &[_][]const u8{base.emit.sub_path}); | 289 | const full_out_path = try directory.join(arena, &[_][]const u8{base.emit.sub_path}); |
| 290 | const full_out_path_z = try arena.dupeZ(u8, full_out_path); | 290 | const full_out_path_z = try arena.dupeSentinel(u8, full_out_path, 0); |
| 291 | const opt_zcu = comp.zcu; | 291 | const opt_zcu = comp.zcu; |
| 292 | 292 | ||
| 293 | const zcu_obj_path: ?Cache.Path = if (opt_zcu != null) p: { | 293 | const zcu_obj_path: ?Cache.Path = if (opt_zcu != null) p: { |
| ... | @@ -326,7 +326,7 @@ fn linkAsArchive(lld: *Lld, arena: Allocator) !void { | ... | @@ -326,7 +326,7 @@ fn linkAsArchive(lld: *Lld, arena: Allocator) !void { |
| 326 | object_files.appendAssumeCapacity(try key.status.success.object_path.toStringZ(arena)); | 326 | object_files.appendAssumeCapacity(try key.status.success.object_path.toStringZ(arena)); |
| 327 | } | 327 | } |
| 328 | for (comp.win32_resource_table.keys()) |key| { | 328 | for (comp.win32_resource_table.keys()) |key| { |
| 329 | object_files.appendAssumeCapacity(try arena.dupeZ(u8, key.status.success.res_path)); | 329 | object_files.appendAssumeCapacity(try arena.dupeSentinel(u8, key.status.success.res_path, 0)); |
| 330 | } | 330 | } |
| 331 | if (zcu_obj_path) |p| object_files.appendAssumeCapacity(try p.toStringZ(arena)); | 331 | if (zcu_obj_path) |p| object_files.appendAssumeCapacity(try p.toStringZ(arena)); |
| 332 | if (compiler_rt_path) |p| object_files.appendAssumeCapacity(try p.toStringZ(arena)); | 332 | if (compiler_rt_path) |p| object_files.appendAssumeCapacity(try p.toStringZ(arena)); |
src/main.zig+2-2| ... | @@ -5971,7 +5971,7 @@ extern "c" fn ZigLlvmAr_main(argc: c_int, argv: [*:null]?[*:0]u8) c_int; | ... | @@ -5971,7 +5971,7 @@ extern "c" fn ZigLlvmAr_main(argc: c_int, argv: [*:null]?[*:0]u8) c_int; |
| 5971 | fn argsCopyZ(alloc: Allocator, args: []const []const u8) ![:null]?[*:0]u8 { | 5971 | fn argsCopyZ(alloc: Allocator, args: []const []const u8) ![:null]?[*:0]u8 { |
| 5972 | var argv = try alloc.allocSentinel(?[*:0]u8, args.len, null); | 5972 | var argv = try alloc.allocSentinel(?[*:0]u8, args.len, null); |
| 5973 | for (args, 0..) |arg, i| { | 5973 | for (args, 0..) |arg, i| { |
| 5974 | argv[i] = try alloc.dupeZ(u8, arg); // TODO If there was an argsAllocZ we could avoid this allocation. | 5974 | argv[i] = try alloc.dupeSentinel(u8, arg, 0); // TODO If there was an argsAllocZ we could avoid this allocation. |
| 5975 | } | 5975 | } |
| 5976 | return argv; | 5976 | return argv; |
| 5977 | } | 5977 | } |
| ... | @@ -6601,7 +6601,7 @@ fn cmdDumpLlvmInts( | ... | @@ -6601,7 +6601,7 @@ fn cmdDumpLlvmInts( |
| 6601 | if (!build_options.have_llvm) | 6601 | if (!build_options.have_llvm) |
| 6602 | fatal("compiler does not use LLVM; cannot dump LLVM integer sizes", .{}); | 6602 | fatal("compiler does not use LLVM; cannot dump LLVM integer sizes", .{}); |
| 6603 | 6603 | ||
| 6604 | const triple = try arena.dupeZ(u8, args[0]); | 6604 | const triple = try arena.dupeSentinel(u8, args[0], 0); |
| 6605 | 6605 | ||
| 6606 | const llvm = @import("codegen/llvm/bindings.zig"); | 6606 | const llvm = @import("codegen/llvm/bindings.zig"); |
| 6607 | 6607 |
tools/docgen.zig+1-1| ... | @@ -679,7 +679,7 @@ fn tokenizeAndPrintRaw( | ... | @@ -679,7 +679,7 @@ fn tokenizeAndPrintRaw( |
| 679 | raw_src: []const u8, | 679 | raw_src: []const u8, |
| 680 | ) !void { | 680 | ) !void { |
| 681 | const src_non_terminated = mem.trim(u8, raw_src, " \r\n"); | 681 | const src_non_terminated = mem.trim(u8, raw_src, " \r\n"); |
| 682 | const src = try allocator.dupeZ(u8, src_non_terminated); | 682 | const src = try allocator.dupeSentinel(u8, src_non_terminated, 0); |
| 683 | 683 | ||
| 684 | try out.writeAll("<code>"); | 684 | try out.writeAll("<code>"); |
| 685 | var tokenizer = std.zig.Tokenizer.init(src); | 685 | var tokenizer = std.zig.Tokenizer.init(src); |
tools/doctest.zig+1-1| ... | @@ -607,7 +607,7 @@ fn printSourceBlock(arena: Allocator, out: *Writer, source_bytes: []const u8, na | ... | @@ -607,7 +607,7 @@ fn printSourceBlock(arena: Allocator, out: *Writer, source_bytes: []const u8, na |
| 607 | 607 | ||
| 608 | fn tokenizeAndPrint(arena: Allocator, out: *Writer, raw_src: []const u8) !void { | 608 | fn tokenizeAndPrint(arena: Allocator, out: *Writer, raw_src: []const u8) !void { |
| 609 | const src_non_terminated = mem.trim(u8, raw_src, " \r\n"); | 609 | const src_non_terminated = mem.trim(u8, raw_src, " \r\n"); |
| 610 | const src = try arena.dupeZ(u8, src_non_terminated); | 610 | const src = try arena.dupeSentinel(u8, src_non_terminated, 0); |
| 611 | 611 | ||
| 612 | try out.writeAll("<code>"); | 612 | try out.writeAll("<code>"); |
| 613 | var tokenizer = std.zig.Tokenizer.init(src); | 613 | var tokenizer = std.zig.Tokenizer.init(src); |