diff options
| author | Ryan Liptak <squeek502@hotmail.com> | 2024-07-13 15:03:55 -0700 |
|---|---|---|
| committer | Ryan Liptak <squeek502@hotmail.com> | 2024-07-13 17:48:08 -0700 |
| commit | 10914dc31000bc5c3b7164a4101808719d3da07f (patch) | |
| tree | 6e9c9f72fb9145a837375243617d8dc6449ed987 /lib/std/process.zig | |
| parent | 944c6d40ce520f345450a15006498dd760fc3d3a (diff) | |
| download | zig-10914dc31000bc5c3b7164a4101808719d3da07f.tar.gz zig-10914dc31000bc5c3b7164a4101808719d3da07f.zip | |
ArgIteratorWindows: Clarify buffer length comment
Diffstat (limited to 'lib/std/process.zig')
| -rw-r--r-- | lib/std/process.zig | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/std/process.zig b/lib/std/process.zig index d40753f19d..542376f580 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -683,10 +683,12 @@ pub const ArgIteratorWindows = struct { const wtf8_len = unicode.calcWtf8Len(cmd_line); // This buffer must be large enough to contain contiguous NUL-terminated slices - // of each argument. For arguments past the first one, space for the NUL-terminator - // is guaranteed due to the necessary whitespace between arugments. However, we need - // one extra byte to guarantee enough room for the NUL terminator if the command line - // ends up being exactly 1 argument long with no quotes, etc. + // of each argument. + // - During parsing, the length of a parsed argument will always be equal to + // to less than its unparsed length + // - The first argument needs one extra byte of space allocated for its NUL + // terminator, but for each subsequent argument the necessary whitespace + // between arguments guarantees room for their NUL terminator(s). const buffer = try allocator.alloc(u8, wtf8_len + 1); errdefer allocator.free(buffer); |
