Pool module

pool_allocator_proc

procedureSource

The Allocator_Proc for a pool: use it as Allocator.{ pool_allocator_proc, *pool }.

Allocate and resize take memory from the pool (a resize copies, and never reuses the old space); free does nothing; shutdown calls release. IS_THIS_YOURS is answered for addresses inside any block the pool has handed out, ordinary or oversized. Unsupported modes fail an assert.

Example↗
pool: Pool;
set_allocators(*pool); // blocks come from the allocator in effect now
defer release(*pool);

push_allocator(Allocator.{ pool_allocator_proc, *pool });
text := copy_string("in the pool");
assert(text == "in the pool");
pool_allocator_proc :: (
    mode: Allocator_Mode,
    requested_size: s64,
    old_size: s64,
    old_memory: *void,
    allocator_data: *void
) -> *void

Parameters

mode: Allocator_Mode
requested_size: s64
old_size: s64
old_memory: *void
allocator_data: *void

Returns

*void

See also