Skip to content

Engine → Core

pool_allocator.h

Declarations for pool_allocator.h.

Structs

File Description
memory::pool_allocator::free_block
memory::pool_allocator::slab

Classes

File Description
memory::pool_allocator Fixed-size block allocator. Blocks are carved from slabs of blocksPerSlab blocks; the pool grows by one slab whenever the free list is empty (up to maxSlabs when a cap is given) and shrink_to_fit() returns slabs with no live block. Blocks are pure data: a block is only used as a free-list link while it is free, so a 16 KiB block really holds 16 KiB. allocate() and deallocate() are O(log slabCount): a sorted slab table resolves the owning slab, which keeps per-slab live counts exact and lets every slab carry a free bitmap, so a double free is detected (asserted and ignored) even while neighbouring blocks are live. Every byte the pool holds, the slab table included, comes from tracked_allocate: the pool is fully counted and never throws. Not thread-safe: the ECS wraps a pool under its own lock.