authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-06-01 01:48:42-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:47:58-07:00
logcab79b0877e9e7239045dc55d3b2bcff190016cb
tree8676069af7736ca931f97fcc7c3f99a404d80e66
parent0777e98bfe89eadeaa0e34a2ad07cf61cdf5b26a

lib: add const to avoid regression

Not sure if this was meant to be legal or not, but either way this code should have been using const anyway.

1 files changed, 4 insertions(+), 4 deletions(-)

lib/std/child_process.zig+4-4
...@@ -530,7 +530,7 @@ pub const ChildProcess = struct {...@@ -530,7 +530,7 @@ pub const ChildProcess = struct {
530 // can fail between fork() and execve().530 // can fail between fork() and execve().
531 // Therefore, we do all the allocation for the execve() before the fork().531 // Therefore, we do all the allocation for the execve() before the fork().
532 // This means we must do the null-termination of argv and env vars here.532 // This means we must do the null-termination of argv and env vars here.
533 const argv_buf = try arena.allocSentinel(?[*:0]u8, self.argv.len, null);533 const argv_buf = try arena.allocSentinel(?[*:0]const u8, self.argv.len, null);
534 for (self.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr;534 for (self.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr;
535535
536 const envp = m: {536 const envp = m: {
...@@ -542,7 +542,7 @@ pub const ChildProcess = struct {...@@ -542,7 +542,7 @@ pub const ChildProcess = struct {
542 } else if (builtin.output_mode == .Exe) {542 } else if (builtin.output_mode == .Exe) {
543 // Then we have Zig start code and this works.543 // Then we have Zig start code and this works.
544 // TODO type-safety for null-termination of `os.environ`.544 // TODO type-safety for null-termination of `os.environ`.
545 break :m @ptrCast([*:null]?[*:0]u8, os.environ.ptr);545 break :m @ptrCast([*:null]?[*:0]const u8, os.environ.ptr);
546 } else {546 } else {
547 // TODO come up with a solution for this.547 // TODO come up with a solution for this.
548 @compileError("missing std lib enhancement: ChildProcess implementation has no way to collect the environment variables to forward to the child process");548 @compileError("missing std lib enhancement: ChildProcess implementation has no way to collect the environment variables to forward to the child process");
...@@ -1425,9 +1425,9 @@ pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const EnvMap) !...@@ -1425,9 +1425,9 @@ pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const EnvMap) !
1425 return try allocator.realloc(result, i);1425 return try allocator.realloc(result, i);
1426}1426}
14271427
1428pub fn createNullDelimitedEnvMap(arena: mem.Allocator, env_map: *const EnvMap) ![:null]?[*:0]u8 {1428pub fn createNullDelimitedEnvMap(arena: mem.Allocator, env_map: *const EnvMap) ![:null]?[*:0]const u8 {
1429 const envp_count = env_map.count();1429 const envp_count = env_map.count();
1430 const envp_buf = try arena.allocSentinel(?[*:0]u8, envp_count, null);1430 const envp_buf = try arena.allocSentinel(?[*:0]const u8, envp_count, null);
1431 {1431 {
1432 var it = env_map.iterator();1432 var it = env_map.iterator();
1433 var i: usize = 0;1433 var i: usize = 0;