authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2024-07-13 15:03:55-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2024-07-13 17:48:08-07:00
log10914dc31000bc5c3b7164a4101808719d3da07f
tree6e9c9f72fb9145a837375243617d8dc6449ed987
parent944c6d40ce520f345450a15006498dd760fc3d3a

ArgIteratorWindows: Clarify buffer length comment


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

lib/std/process.zig+6-4
...@@ -683,10 +683,12 @@ pub const ArgIteratorWindows = struct {...@@ -683,10 +683,12 @@ pub const ArgIteratorWindows = struct {
683 const wtf8_len = unicode.calcWtf8Len(cmd_line);683 const wtf8_len = unicode.calcWtf8Len(cmd_line);
684684
685 // This buffer must be large enough to contain contiguous NUL-terminated slices685 // This buffer must be large enough to contain contiguous NUL-terminated slices
686 // of each argument. For arguments past the first one, space for the NUL-terminator686 // of each argument.
687 // is guaranteed due to the necessary whitespace between arugments. However, we need687 // - During parsing, the length of a parsed argument will always be equal to
688 // one extra byte to guarantee enough room for the NUL terminator if the command line688 // to less than its unparsed length
689 // ends up being exactly 1 argument long with no quotes, etc.689 // - The first argument needs one extra byte of space allocated for its NUL
690 // terminator, but for each subsequent argument the necessary whitespace
691 // between arguments guarantees room for their NUL terminator(s).
690 const buffer = try allocator.alloc(u8, wtf8_len + 1);692 const buffer = try allocator.alloc(u8, wtf8_len + 1);
691 errdefer allocator.free(buffer);693 errdefer allocator.free(buffer);
692694