Skip to content
PAGE_ALLOCATOR_MAGIC

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 / SlabAllocator reinterpreted as a PageAllocator * is rejected at runtime as type-confusion.

Usage example (Cross-references)

Usage examples (Cross-references)
                       .effort          = ALLOCATOR_EFFORT_ONCE,                                                                 \
                       .retry_limit     = 0,                                                                                     \
                       .__magic         = PAGE_ALLOCATOR_MAGIC | MAGIC_VALIDATED_BIT,                                                                  \
                       .footprint_bytes = 0},                                                                                    \
            .cached_page_size   = 0,                                                                                       \
                       .effort          = ALLOCATOR_EFFORT_ONCE,                                                                 \
                       .retry_limit     = 0,                                                                                     \
                       .__magic         = PAGE_ALLOCATOR_MAGIC | MAGIC_VALIDATED_BIT,                                                                  \
                       .footprint_bytes = 0},                                                                                    \
            .cached_page_size   = 0,                                                                                       \
            LOG_FATAL("DebugAllocator: embedded meta has bad magic");
        }
        if (!MAGIC_MATCHES(self->page.base.__magic, PAGE_ALLOCATOR_MAGIC)) {
            LOG_FATAL("DebugAllocator: embedded page has bad magic");
        }
            LOG_FATAL("PageAllocator: NULL self");
        }
        if (!MAGIC_MATCHES(pg->base.__magic, PAGE_ALLOCATOR_MAGIC)) {
            LOG_FATAL("type-confusion: allocator passed to page_allocator_* is not a PageAllocator");
        }
Last updated on