mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.process.ArgIteratorWasi: fix no-args deinit
This commit is contained in:
parent
be9649f4ea
commit
cb115cf73a
1 changed files with 3 additions and 0 deletions
|
|
@ -690,6 +690,9 @@ pub const ArgIteratorWasi = struct {
|
||||||
|
|
||||||
/// Call to free the internal buffer of the iterator.
|
/// Call to free the internal buffer of the iterator.
|
||||||
pub fn deinit(self: *ArgIteratorWasi) void {
|
pub fn deinit(self: *ArgIteratorWasi) void {
|
||||||
|
// Nothing is allocated when there are no args
|
||||||
|
if (self.args.len == 0) return;
|
||||||
|
|
||||||
const last_item = self.args[self.args.len - 1];
|
const last_item = self.args[self.args.len - 1];
|
||||||
const last_byte_addr = @intFromPtr(last_item.ptr) + last_item.len + 1; // null terminated
|
const last_byte_addr = @intFromPtr(last_item.ptr) + last_item.len + 1; // null terminated
|
||||||
const first_item_ptr = self.args[0].ptr;
|
const first_item_ptr = self.args[0].ptr;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue