Skip to content
ARENA_ALLOCATOR_MAGIC

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)
                       .effort          = ALLOCATOR_EFFORT_ONCE,                                                                 \
                       .retry_limit     = 0,                                                                                     \
                       .__magic         = ARENA_ALLOCATOR_MAGIC | MAGIC_VALIDATED_BIT,                                                                 \
                       .footprint_bytes = 0},                                                                                    \
            .head      = NULL,                                                                                             \
                       .effort          = ALLOCATOR_EFFORT_ONCE,                                                                 \
                       .retry_limit     = 0,                                                                                     \
                       .__magic         = ARENA_ALLOCATOR_MAGIC | MAGIC_VALIDATED_BIT,                                                                 \
                       .footprint_bytes = 0},                                                                                    \
            .head      = NULL,                                                                                             \
            LOG_FATAL("ArenaAllocator: NULL self");
        }
        if (!MAGIC_MATCHES(self->base.__magic, ARENA_ALLOCATOR_MAGIC)) {
            LOG_FATAL("type-confusion: allocator passed to arena_allocator_* is not an ArenaAllocator");
        }
Last updated on