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 {
530530 // can fail between fork() and execve().
531531 // Therefore, we do all the allocation for the execve() before the fork().
532532 // 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);
534534 for (self.argv, 0..) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr;
535535
536536 const envp = m: {
......@@ -542,7 +542,7 @@ pub const ChildProcess = struct {
542542 } else if (builtin.output_mode == .Exe) {
543543 // Then we have Zig start code and this works.
544544 // 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);
546546 } else {
547547 // TODO come up with a solution for this.
548548 @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) !
14251425 return try allocator.realloc(result, i);
14261426}
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 {
14291429 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);
14311431 {
14321432 var it = env_map.iterator();
14331433 var i: usize = 0;