Pool module

set_allocators

procedureSource

Chooses the allocator the pool takes its blocks from: block_allocator if given, else context.allocator.

The first get calls it when nothing was chosen. Calling it again once an allocator is set logs an error and changes nothing. With the module parameter USE_UNMAPPING_ALLOCATOR the default is the unmapping allocator and free_memblocks_on_reset is turned on.

Example↗
pool: Pool;
set_allocators(*pool);
defer release(*pool);
assert(get(*pool, 8) != null);
set_allocators :: (pool: *Pool, block_allocator: Allocator = .{})

Parameters

pool: *Pool
block_allocator: Allocator = .{}

See also