Function create [src]
Returns a pointer to undefined memory.
Call destroy with the result to free the memory.
Prototype
pub fn create(a: Allocator, comptime T: type) Error!*T
Parameters
a: Allocator
T: type
Possible Errors
Source
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.allocBytesWithAlignment(.of(T), @sizeOf(T), @returnAddress()));
return ptr;
}