pub fn free(self: Allocator, memory: anytype) void self: Allocatormemory448
449
450
451
452
453
454
455
456
457pub fn free(self: Allocator, memory: anytype) void {
const slice_info = @typeInfo(@TypeOf(memory)).pointer;
if (slice_info.size != .slice) {
comptime assert(slice_info.size == .one and @typeInfo(slice_info.child) == .array);
}
const bytes: []u8 = @ptrCast(@constCast(mem.absorbSentinel(memory)));
if (bytes.len == 0) return;
@memset(bytes, undefined);
self.rawFree(bytes, .fromByteUnits(slice_info.attrs.@"align" orelse @alignOf(slice_info.child)), @returnAddress());
}
Free an array allocated with
alloc. If memory has length 0, free is a no-op. To free a single item, seedestroy.