Skip to content
BUDGET_ALLOCATOR_MAGIC

BUDGET_ALLOCATOR_MAGIC

Description

Per-type magic for BudgetAllocator. Stamped into Allocator.base.__magic by BudgetAllocatorInit*. The budget implementation functions validate this exact value so other allocator instances reinterpreted as a BudgetAllocator * are rejected at runtime as type-confusion.

Usage example (Cross-references)

Usage examples (Cross-references)
                        .effort          = ALLOCATOR_EFFORT_ONCE,                                                                \
                        .retry_limit     = 0,                                                                                    \
                        .__magic         = BUDGET_ALLOCATOR_MAGIC | MAGIC_VALIDATED_BIT,                                                               \
                        .footprint_bytes = 0},                                                                                   \
             .buf          = (u8 *)(buf_ptr),                                                                              \
            LOG_FATAL("BudgetAllocator: NULL self");
        }
        if (!MAGIC_MATCHES(self->base.__magic, BUDGET_ALLOCATOR_MAGIC)) {
            LOG_FATAL("type-confusion: allocator passed to budget_allocator_* is not a BudgetAllocator");
        }
Last updated on