mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
std: clean up imports in a couple files
This commit is contained in:
parent
3a8117439d
commit
6b0d773266
@ -355,7 +355,7 @@ pub const GetEnvVarOwnedError = error{
|
||||
};
|
||||
|
||||
/// Caller must free returned memory.
|
||||
pub fn getEnvVarOwned(allocator: mem.Allocator, key: []const u8) GetEnvVarOwnedError![]u8 {
|
||||
pub fn getEnvVarOwned(allocator: Allocator, key: []const u8) GetEnvVarOwnedError![]u8 {
|
||||
if (builtin.os.tag == .windows) {
|
||||
const result_w = blk: {
|
||||
const key_w = try std.unicode.utf8ToUtf16LeWithNull(allocator, key);
|
||||
@ -430,7 +430,7 @@ pub const ArgIteratorPosix = struct {
|
||||
};
|
||||
|
||||
pub const ArgIteratorWasi = struct {
|
||||
allocator: mem.Allocator,
|
||||
allocator: Allocator,
|
||||
index: usize,
|
||||
args: [][:0]u8,
|
||||
|
||||
@ -438,7 +438,7 @@ pub const ArgIteratorWasi = struct {
|
||||
|
||||
/// You must call deinit to free the internal buffer of the
|
||||
/// iterator after you are done.
|
||||
pub fn init(allocator: mem.Allocator) InitError!ArgIteratorWasi {
|
||||
pub fn init(allocator: Allocator) InitError!ArgIteratorWasi {
|
||||
const fetched_args = try ArgIteratorWasi.internalInit(allocator);
|
||||
return ArgIteratorWasi{
|
||||
.allocator = allocator,
|
||||
@ -447,7 +447,7 @@ pub const ArgIteratorWasi = struct {
|
||||
};
|
||||
}
|
||||
|
||||
fn internalInit(allocator: mem.Allocator) InitError![][:0]u8 {
|
||||
fn internalInit(allocator: Allocator) InitError![][:0]u8 {
|
||||
const w = os.wasi;
|
||||
var count: usize = undefined;
|
||||
var buf_size: usize = undefined;
|
||||
@ -760,7 +760,7 @@ pub const ArgIterator = struct {
|
||||
};
|
||||
|
||||
/// You must deinitialize iterator's internal buffers by calling `deinit` when done.
|
||||
pub fn initWithAllocator(allocator: mem.Allocator) InitError!ArgIterator {
|
||||
pub fn initWithAllocator(allocator: Allocator) InitError!ArgIterator {
|
||||
if (builtin.os.tag == .wasi and !builtin.link_libc) {
|
||||
return ArgIterator{ .inner = try InnerType.init(allocator) };
|
||||
}
|
||||
@ -804,7 +804,7 @@ pub fn args() ArgIterator {
|
||||
}
|
||||
|
||||
/// You must deinitialize iterator's internal buffers by calling `deinit` when done.
|
||||
pub fn argsWithAllocator(allocator: mem.Allocator) ArgIterator.InitError!ArgIterator {
|
||||
pub fn argsWithAllocator(allocator: Allocator) ArgIterator.InitError!ArgIterator {
|
||||
return ArgIterator.initWithAllocator(allocator);
|
||||
}
|
||||
|
||||
@ -827,7 +827,7 @@ test "args iterator" {
|
||||
}
|
||||
|
||||
/// Caller must call argsFree on result.
|
||||
pub fn argsAlloc(allocator: mem.Allocator) ![][:0]u8 {
|
||||
pub fn argsAlloc(allocator: Allocator) ![][:0]u8 {
|
||||
// TODO refactor to only make 1 allocation.
|
||||
var it = try argsWithAllocator(allocator);
|
||||
defer it.deinit();
|
||||
@ -864,7 +864,7 @@ pub fn argsAlloc(allocator: mem.Allocator) ![][:0]u8 {
|
||||
return result_slice_list;
|
||||
}
|
||||
|
||||
pub fn argsFree(allocator: mem.Allocator, args_alloc: []const [:0]u8) void {
|
||||
pub fn argsFree(allocator: Allocator, args_alloc: []const [:0]u8) void {
|
||||
var total_bytes: usize = 0;
|
||||
for (args_alloc) |arg| {
|
||||
total_bytes += @sizeOf([]u8) + arg.len + 1;
|
||||
@ -1089,7 +1089,7 @@ pub const ExecvError = std.os.ExecveError || error{OutOfMemory};
|
||||
/// This function also uses the PATH environment variable to get the full path to the executable.
|
||||
/// Due to the heap-allocation, it is illegal to call this function in a fork() child.
|
||||
/// For that use case, use the `std.os` functions directly.
|
||||
pub fn execv(allocator: mem.Allocator, argv: []const []const u8) ExecvError {
|
||||
pub fn execv(allocator: Allocator, argv: []const []const u8) ExecvError {
|
||||
return execve(allocator, argv, null);
|
||||
}
|
||||
|
||||
@ -1102,7 +1102,7 @@ pub fn execv(allocator: mem.Allocator, argv: []const []const u8) ExecvError {
|
||||
/// Due to the heap-allocation, it is illegal to call this function in a fork() child.
|
||||
/// For that use case, use the `std.os` functions directly.
|
||||
pub fn execve(
|
||||
allocator: mem.Allocator,
|
||||
allocator: Allocator,
|
||||
argv: []const []const u8,
|
||||
env_map: ?*const EnvMap,
|
||||
) ExecvError {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user