Skip to content
MISRA_ARENA_ALLOCATOR_MAGIC

MISRA_ARENA_ALLOCATOR_MAGIC

Description

Per-type magic for ArenaAllocator. Stamped into Allocator.base.__magic by ArenaAllocatorInit*. The arena implementation functions validate this exact value so other allocator instances reinterpreted as an ArenaAllocator * are rejected at runtime as type-confusion.

Usage example (Cross-references)

Usage examples (Cross-references)
    
    static void arena_validate_self(const Allocator *self) {
        if (!self || self->__magic != MISRA_ARENA_ALLOCATOR_MAGIC) {
            LOG_FATAL("type-confusion: allocator passed to arena_allocator_* is not an ArenaAllocator");
        }
                       .effort      = ALLOCATOR_EFFORT_ONCE,                                                                     \
                       .retry_limit = 0,                                                                                         \
                       .__magic     = MISRA_ARENA_ALLOCATOR_MAGIC},                                                                  \
            .head      = NULL,                                                                                             \
            .tail      = NULL,                                                                                             \
                       .effort      = ALLOCATOR_EFFORT_ONCE,                                                                     \
                       .retry_limit = 0,                                                                                         \
                       .__magic     = MISRA_ARENA_ALLOCATOR_MAGIC},                                                                  \
            .head      = NULL,                                                                                             \
            .tail      = NULL,                                                                                             \
Last updated on