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)
- In
Page.h:275:
.effort = ALLOCATOR_EFFORT_ONCE, \
.retry_limit = 0, \
.__magic = PAGE_ALLOCATOR_MAGIC | MAGIC_VALIDATED_BIT, \
.footprint_bytes = 0}, \
.cached_page_size = 0, \
- In
Page.h:309:
.effort = ALLOCATOR_EFFORT_ONCE, \
.retry_limit = 0, \
.__magic = PAGE_ALLOCATOR_MAGIC | MAGIC_VALIDATED_BIT, \
.footprint_bytes = 0}, \
.cached_page_size = 0, \
- In
Debug.c:146:
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");
}- In
Page.c:109:
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