#import "std/pool"
Pool allocator is simple growing allocator grouping all allocated memory into memory blocks
of POOL_DEFAULT_SIZE bytes by default.
- [x] Allocate
- [-] Reallocate (Always allocates and copy data into a new block.)
- [-] Free (Keeps memory for later use.)
- [x] Release
- [x] Reset
reset or release is called.N * current_block_size where N is the minimum multiplier needed to store the required
data size.free is called, you should call reset instead
when all previously allocated data can be freed.reset is called) for later use.Note: This allocator is used as a default temporary allocator in the application context.
POOL_DEFAULT_SIZE : usize : 65536
File: pool.bl
PoolAllocator :: struct #base Allocator {
block_size: usize;
allocator: *Allocator;
used_blocks: [..]*u8;
unused_blocks: [..]*u8;
obsolete_blocks: [..]*u8;
current_block: *u8;
top: *u8;
space: usize;
}
Pool allocator type.
block_size - Size of the current block.allocator - Base allocator used to allocate block memory.File: pool.bl
pool_default ::
Default pool allocator instance using the current allocator in application context and POOL_DEFAULT_SIZE.
File: pool.bl
pool_make :: fn (allocator : *Allocator: null, block_size :: POOL_DEFAULT_SIZE) PoolAllocator #inline
Make new pool allocator instance. The allocator is the allocator used internally to allocate
block memory. The block_size is size of each preallocated block in Bytes (note that the block
size can grow over time when bigger continuous memory allocations are required).
File: pool.bl
Warning: Function is marked as obsolete. Since 0.13.0; Use release_allocator instead.
pool_release :: fn (pool: *PoolAllocator)
Release all allocated memory used by pool (allocated in pool.allocator).
File: pool.bl
Warning: Function is marked as obsolete. Since 0.13.0; Use reset_allocator instead.
pool_reset :: fn (pool: *PoolAllocator) #inline
Invalidate all allocations but keep preallocated memory block for later use.
File: pool.bl