std :: alloc::pool
Struct std::PoolAllocator
struct PoolAllocator {
&heap unsigned char base;
int owned;
unsigned long cap;
?&PoolBlock head;
}Fields
heap-backed managed memory
1 if PoolAllocator::new allocated base (destroy() frees it)
total buffer size
first block in the list (walked inside unsafe)
Methods
A pool over a user-provided heap buffer (8-aligned) of cap bytes.
A heap-backed pool of cap bytes.
Allocate size bytes aligned to align. Every block is 8-aligned
(given an 8-aligned buffer: always for PoolAllocator::new), so align is honoured
up to 8 (0 is taken as 1). null if no free block fits, or align is
above 8 or not a power of two.
Free a previously allocated pointer (null: no-op). Coalesces adjacent free blocks. Aborts with a diagnostic on a double free.
Free every block at once: the whole buffer is one free block again (blocks handed out before become invalid).
Return total free bytes (sum of all free blocks).
Free the backing buffer (only valid for heap-backed allocators from PoolAllocator::new).
= drop()