Function argsFree [src]
Prototype
pub fn argsFree(allocator: Allocator, args_alloc: []const [:0]u8) void
Parameters
allocator: Allocator
args_alloc: []const [:0]u8
Source
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;
}
const unaligned_allocated_buf = @as([*]const u8, @ptrCast(args_alloc.ptr))[0..total_bytes];
const aligned_allocated_buf: []align(@alignOf([]u8)) const u8 = @alignCast(unaligned_allocated_buf);
return allocator.free(aligned_allocated_buf);
}