Free an array allocated with alloc.
If memory has length 0, free is a no-op.
To free a single item, see destroy.
pub fn free(self: Allocator, memory: anytype) void
pub fn free(self: Allocator, memory: anytype) void {
const slice_info = @typeInfo(@TypeOf(memory)).pointer;
if (slice_info.size != .slice) {
// slicing with comptime-known start and end results in *[len]T, which may be free'd
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());
}