Skip to content
SLAB_ALLOCATOR_MAGIC

SLAB_ALLOCATOR_MAGIC

Description

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

Usage example (Cross-references)

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