pub fn create(pool: *Pool, allocator: Allocator) Allocator.Error!ItemPtr
Creates a new item and adds it to the memory pool. allocator may be undefined if pool is not growable.
allocator
undefined
growable
pool: *Pool
allocator: Allocator
113 114 115 116 117 118 119 120 121 122 123
pub fn create(pool: *Pool, allocator: Allocator) Allocator.Error!ItemPtr { const ptr: ItemPtr = if (pool.free_list.popFirst()) |node| @ptrCast(@alignCast(node)) else if (pool_options.growable) @ptrCast(try pool.allocNew(allocator)) else return error.OutOfMemory; ptr.* = undefined; return ptr; }
Creates a new item and adds it to the memory pool.
allocatormay beundefinedif pool is notgrowable.