Function destroy [src]

ptr should be the return value of create, or otherwise have the same address and alignment property.

Prototype

pub fn destroy(self: Allocator, ptr: anytype) void

Parameters

self: Allocator

Source

pub fn destroy(self: Allocator, ptr: anytype) void { const info = @typeInfo(@TypeOf(ptr)).pointer; if (info.size != .one) @compileError("ptr must be a single item pointer"); const T = info.child; if (@sizeOf(T) == 0) return; const non_const_ptr = @as([*]u8, @ptrCast(@constCast(ptr))); self.rawFree(non_const_ptr[0..@sizeOf(T)], .fromByteUnits(info.alignment), @returnAddress()); }