authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-11-10 14:00:55-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-06 12:15:04-07:00
log6b0d77326678d198550c0cc3ef7fe82a53e0e508
tree5fb748927dab65fb4f197139cc2b731cf0b50d98
parent3a8117439dce10a92e3c37a7dbf5440a9730ad41

std: clean up imports in a couple files


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

lib/std/process.zig+10-10
...@@ -355,7 +355,7 @@ pub const GetEnvVarOwnedError = error{...@@ -355,7 +355,7 @@ pub const GetEnvVarOwnedError = error{
355};355};
356356
357/// Caller must free returned memory.357/// Caller must free returned memory.
358pub fn getEnvVarOwned(allocator: mem.Allocator, key: []const u8) GetEnvVarOwnedError![]u8 {358pub fn getEnvVarOwned(allocator: Allocator, key: []const u8) GetEnvVarOwnedError![]u8 {
359 if (builtin.os.tag == .windows) {359 if (builtin.os.tag == .windows) {
360 const result_w = blk: {360 const result_w = blk: {
361 const key_w = try std.unicode.utf8ToUtf16LeWithNull(allocator, key);361 const key_w = try std.unicode.utf8ToUtf16LeWithNull(allocator, key);
...@@ -430,7 +430,7 @@ pub const ArgIteratorPosix = struct {...@@ -430,7 +430,7 @@ pub const ArgIteratorPosix = struct {
430};430};
431431
432pub const ArgIteratorWasi = struct {432pub const ArgIteratorWasi = struct {
433 allocator: mem.Allocator,433 allocator: Allocator,
434 index: usize,434 index: usize,
435 args: [][:0]u8,435 args: [][:0]u8,
436436
...@@ -438,7 +438,7 @@ pub const ArgIteratorWasi = struct {...@@ -438,7 +438,7 @@ pub const ArgIteratorWasi = struct {
438438
439 /// You must call deinit to free the internal buffer of the439 /// You must call deinit to free the internal buffer of the
440 /// iterator after you are done.440 /// iterator after you are done.
441 pub fn init(allocator: mem.Allocator) InitError!ArgIteratorWasi {441 pub fn init(allocator: Allocator) InitError!ArgIteratorWasi {
442 const fetched_args = try ArgIteratorWasi.internalInit(allocator);442 const fetched_args = try ArgIteratorWasi.internalInit(allocator);
443 return ArgIteratorWasi{443 return ArgIteratorWasi{
444 .allocator = allocator,444 .allocator = allocator,
...@@ -447,7 +447,7 @@ pub const ArgIteratorWasi = struct {...@@ -447,7 +447,7 @@ pub const ArgIteratorWasi = struct {
447 };447 };
448 }448 }
449449
450 fn internalInit(allocator: mem.Allocator) InitError![][:0]u8 {450 fn internalInit(allocator: Allocator) InitError![][:0]u8 {
451 const w = os.wasi;451 const w = os.wasi;
452 var count: usize = undefined;452 var count: usize = undefined;
453 var buf_size: usize = undefined;453 var buf_size: usize = undefined;
...@@ -760,7 +760,7 @@ pub const ArgIterator = struct {...@@ -760,7 +760,7 @@ pub const ArgIterator = struct {
760 };760 };
761761
762 /// You must deinitialize iterator's internal buffers by calling `deinit` when done.762 /// You must deinitialize iterator's internal buffers by calling `deinit` when done.
763 pub fn initWithAllocator(allocator: mem.Allocator) InitError!ArgIterator {763 pub fn initWithAllocator(allocator: Allocator) InitError!ArgIterator {
764 if (builtin.os.tag == .wasi and !builtin.link_libc) {764 if (builtin.os.tag == .wasi and !builtin.link_libc) {
765 return ArgIterator{ .inner = try InnerType.init(allocator) };765 return ArgIterator{ .inner = try InnerType.init(allocator) };
766 }766 }
...@@ -804,7 +804,7 @@ pub fn args() ArgIterator {...@@ -804,7 +804,7 @@ pub fn args() ArgIterator {
804}804}
805805
806/// You must deinitialize iterator's internal buffers by calling `deinit` when done.806/// You must deinitialize iterator's internal buffers by calling `deinit` when done.
807pub fn argsWithAllocator(allocator: mem.Allocator) ArgIterator.InitError!ArgIterator {807pub fn argsWithAllocator(allocator: Allocator) ArgIterator.InitError!ArgIterator {
808 return ArgIterator.initWithAllocator(allocator);808 return ArgIterator.initWithAllocator(allocator);
809}809}
810810
...@@ -827,7 +827,7 @@ test "args iterator" {...@@ -827,7 +827,7 @@ test "args iterator" {
827}827}
828828
829/// Caller must call argsFree on result.829/// Caller must call argsFree on result.
830pub fn argsAlloc(allocator: mem.Allocator) ![][:0]u8 {830pub fn argsAlloc(allocator: Allocator) ![][:0]u8 {
831 // TODO refactor to only make 1 allocation.831 // TODO refactor to only make 1 allocation.
832 var it = try argsWithAllocator(allocator);832 var it = try argsWithAllocator(allocator);
833 defer it.deinit();833 defer it.deinit();
...@@ -864,7 +864,7 @@ pub fn argsAlloc(allocator: mem.Allocator) ![][:0]u8 {...@@ -864,7 +864,7 @@ pub fn argsAlloc(allocator: mem.Allocator) ![][:0]u8 {
864 return result_slice_list;864 return result_slice_list;
865}865}
866866
867pub fn argsFree(allocator: mem.Allocator, args_alloc: []const [:0]u8) void {867pub fn argsFree(allocator: Allocator, args_alloc: []const [:0]u8) void {
868 var total_bytes: usize = 0;868 var total_bytes: usize = 0;
869 for (args_alloc) |arg| {869 for (args_alloc) |arg| {
870 total_bytes += @sizeOf([]u8) + arg.len + 1;870 total_bytes += @sizeOf([]u8) + arg.len + 1;
...@@ -1089,7 +1089,7 @@ pub const ExecvError = std.os.ExecveError || error{OutOfMemory};...@@ -1089,7 +1089,7 @@ pub const ExecvError = std.os.ExecveError || error{OutOfMemory};
1089/// This function also uses the PATH environment variable to get the full path to the executable.1089/// This function also uses the PATH environment variable to get the full path to the executable.
1090/// Due to the heap-allocation, it is illegal to call this function in a fork() child.1090/// Due to the heap-allocation, it is illegal to call this function in a fork() child.
1091/// For that use case, use the `std.os` functions directly.1091/// For that use case, use the `std.os` functions directly.
1092pub fn execv(allocator: mem.Allocator, argv: []const []const u8) ExecvError {1092pub fn execv(allocator: Allocator, argv: []const []const u8) ExecvError {
1093 return execve(allocator, argv, null);1093 return execve(allocator, argv, null);
1094}1094}
10951095
...@@ -1102,7 +1102,7 @@ pub fn execv(allocator: mem.Allocator, argv: []const []const u8) ExecvError {...@@ -1102,7 +1102,7 @@ pub fn execv(allocator: mem.Allocator, argv: []const []const u8) ExecvError {
1102/// Due to the heap-allocation, it is illegal to call this function in a fork() child.1102/// Due to the heap-allocation, it is illegal to call this function in a fork() child.
1103/// For that use case, use the `std.os` functions directly.1103/// For that use case, use the `std.os` functions directly.
1104pub fn execve(1104pub fn execve(
1105 allocator: mem.Allocator,1105 allocator: Allocator,
1106 argv: []const []const u8,1106 argv: []const []const u8,
1107 env_map: ?*const EnvMap,1107 env_map: ?*const EnvMap,
1108) ExecvError {1108) ExecvError {