pub fn create(a: Allocator, comptime T: type) Error!*T
Returns a pointer to undefined memory. Call destroy with the result to free the memory.
destroy
a: Allocator
T: type
OutOfMemory
170 171 172 173 174 175 176 177
pub fn create(a: Allocator, comptime T: type) Error!*T { if (@sizeOf(T) == 0) { const ptr = comptime std.mem.alignBackward(usize, math.maxInt(usize), @alignOf(T)); return @ptrFromInt(ptr); } const ptr: *T = @ptrCast(try a.allocBytesAligned(.of(T), @sizeOf(T), @returnAddress())); return ptr; }
Returns a pointer to undefined memory. Call
destroywith the result to free the memory.