Skip to main content

declare_global_allocator

Macro declare_global_allocator 

Source
macro_rules! declare_global_allocator {
    ($name:ident, $max_blocks:expr, $block_size:expr $(,)?) => { ... };
}
Expand description

Declare a static BoundedAllocator registered as #[global_allocator], computing the bitmap word count from MAX_BLOCKS automatically.

§Example

taktora_bounded_alloc::declare_global_allocator!(ALLOC, 512, 1024);

Expands to roughly:

#[global_allocator]
static ALLOC: taktora_bounded_alloc::BoundedAllocator<512, 1024, 8> =
    taktora_bounded_alloc::BoundedAllocator::new();