PageAllocatorAligned
Description
Create a page-backed allocator with a custom alignment floor. Allocations always honor at least page-size alignment - which is what mmap / VirtualAlloc guarantee. Requests for alignment stronger than the page size are not honored by this allocator: a future allocator backend will offer that capability by over-mapping and trimming.
Parameters
| Name | Direction | Description |
|---|---|---|
alignment |
in | Required minimum alignment in bytes. |
Success
Returns a page-backed allocator descriptor with the requested minimum alignment.
Failure
Function cannot fail.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Page.c:183:
}
Allocator PageAllocatorAligned(size alignment) {
Allocator alloc = PageAllocator();
if (alignment) { // assert page-alignment here since that is what mmap guarantees
// portably.
Allocator alloc = PageAllocatorAligned(64);
size page = PageAllocatorPageSize();
void *ptr = AllocatorAlloc(&alloc, 1024, true);
Last updated on