Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "alloc/pool"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
block |
alloc/block |
pool.dodo |
error |
alloc/error |
pool.dodo |
layout |
alloc/layout |
pool.dodo |
mem |
core/mem |
pool.dodo |
ptr |
core/ptr |
pool.dodo |
Pool
Struct · Source
A fixed-block allocator with an intrusive free list. Metadata occupies free blocks only; allocating and freeing take constant time and never allocate.
pub struct Pool {
// Private implementation fields omitted.
}
Pool.new
Function · Source
Blocks are padded to hold an aligned usize free-list entry. Capacity reflects this padding and any initial backing-address alignment loss.
pub fn new(backing: &mut[u8], block_size: usize, block_align: usize) -> Pool!error.AllocError from(backing)
Pool.capacity
Function · Source
pub fn capacity(&self) -> usize
Pool.available
Function · Source
pub fn available(&self) -> usize
Pool.block_size
Function · Source
pub fn block_size(&self) -> usize
Pool.block_align
Function · Source
pub fn block_align(&self) -> usize
Pool.allocate
Function · Source
pub fn allocate(&mut self, requested: &layout.Layout) -> block.Block!error.AllocError
Pool.allocate_zeroed
Function · Source
pub fn allocate_zeroed(&mut self, requested: &layout.Layout) -> block.Block!error.AllocError
Pool.deallocate
Function · Source
SAFETY: allocated is a currently live block from this exact pool, freed at most once. Destroy its values and stop using its pointers before this call. Blocks from another pool or a previous reset are invalid.
pub unsafe fn deallocate(&mut self, allocated: block.Block)
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
Pool.reset
Function · Source
SAFETY: destroy all values first. All outstanding pointers and blocks become invalid, including descriptors that have not been deallocated.
pub unsafe fn reset(&mut self)
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.