Skip to content
MISRA_PAGE_ALLOCATOR_MAGIC

MISRA_PAGE_ALLOCATOR_MAGIC

Description

Per-type magic for PageAllocator. Stamped into Allocator.base.__magic by PageAllocatorInit*. The page implementation functions validate this exact value so a HeapAllocator / ArenaAllocator / PoolAllocator reinterpreted as a PageAllocator * is rejected at runtime as type-confusion.

Usage example (Cross-references)

Usage examples (Cross-references)
    
    static void page_validate_self(const Allocator *self) {
        if (!self || self->__magic != MISRA_PAGE_ALLOCATOR_MAGIC) {
            LOG_FATAL("type-confusion: allocator passed to page_allocator_* is not a PageAllocator");
        }
                       .effort      = ALLOCATOR_EFFORT_ONCE,                                                                     \
                       .retry_limit = 0,                                                                                         \
                       .__magic     = MISRA_PAGE_ALLOCATOR_MAGIC},                                                                   \
            .cached_page_size = 0                                                                                          \
        })
                       .effort      = ALLOCATOR_EFFORT_ONCE,                                                                     \
                       .retry_limit = 0,                                                                                         \
                       .__magic     = MISRA_PAGE_ALLOCATOR_MAGIC},                                                                   \
            .cached_page_size = 0                                                                                          \
        })
Last updated on