SlabAllocatorInitAligned
Description
Initialize a SlabAllocator with a custom alignment floor. alignment_value must not exceed slot_size_bytes; alignments stronger than MAX_ALIGN are accepted but the underlying slab page guarantees only MAX_ALIGN so over-strong alignment is the caller’s responsibility to honour at use.
slot_size_bytes and alignment_value MUST both be side-effect-free. Both expand through ternary cascades that evaluate the argument many times. Pass literals or const locals.
Success
Returns a fully-initialised SlabAllocator value with the requested slot size and alignment floor recorded in the base.
Failure
Cannot fail at macro-expansion time. Invalid slot size / alignment combinations are caught on first allocation by the validator.
Usage example (Cross-references)
Usage examples (Cross-references)
static bool test_pool_alignment(void) {
SlabAllocator slab = SlabAllocatorInitAligned(sizeof(int), 64);
Allocator *alloc_base = ALLOCATOR_OF(&slab);
int *p = (int *)AllocatorAlloc(alloc_base, sizeof(int), true);
Last updated on