Skip to content
BudgetAllocatorInitAligned

BudgetAllocatorInitAligned

Description

Initialize a BudgetAllocator with a caller-supplied alignment. alignment must be a power of two and at least sizeof(void *); slot size is rounded up to it. Otherwise identical to BudgetAllocatorInit.

Parameters

Name Direction Description
alignment in Required slot alignment in bytes (power of two).

Success

Returns a fully-initialized BudgetAllocator value with bitmap zeroed.

Failure

Aborts via LOG_FATAL on bad arguments (see BudgetAllocatorInit) or when alignment is not a power-of-two or is below sizeof(void *).

Usage example (Cross-references)

Usage examples (Cross-references)
    ///
    #define BudgetAllocatorInit(buf_ptr, total_bytes, slot_size_bytes)                                                     \
        BudgetAllocatorInitAligned((buf_ptr), (total_bytes), (slot_size_bytes), sizeof(void *))
    
    ///
        static u8 buf[1024];
        MemSet(buf, 0, sizeof(buf));
        BudgetAllocator bp    = BudgetAllocatorInitAligned(buf, sizeof(buf), sizeof(int), 64);
        Allocator      *alloc = ALLOCATOR_OF(&bp);
        int            *p1    = (int *)AllocatorAlloc(alloc, sizeof(int), true);
Last updated on