Pool module

get

procedureSource

Returns nbytes bytes aligned to the pool's alignment, or null when the underlying allocator fails or the size is too large to represent.

The memory is uninitialized and stays valid until reset or release. A size of zero is fine. A non-power-of-two alignment or a negative size fails an assert.

Example↗
pool: Pool;
defer release(*pool);
a := cast(*int) get(*pool, size_of(int));
b := cast(*int) get(*pool, size_of(int));
a.* = 1;
b.* = 2;
assert(a.* == 1 && b.* == 2);
get :: (pool: *Pool, nbytes: s64) -> *void

Parameters

pool: *Pool
nbytes: s64

Returns

*void

See also