allocators/core
sourceallocators/core.sx
pub type Arena = { buf: ref void, offset: usize, cap: usize }
Fields
| Name | Type |
|---|
buf | ref void |
offset | usize |
cap | usize |
pub enum AllocError = { OutOfMemory }
Variants
pub fn (Arena) new(capacity: usize) result[Allocator, AllocError] = trust { ... }
pub fn (Arena) free(arena: mut Arena) void = trust { ... }
pub fn (Arena) alloc(arena: Arena, size: usize) option[ref void]
pub fn (Arena) used(arena: Arena) usize
pub fn (Arena) cap(arena: Arena) usize
pub fn (Arena) remaining(arena: Arena) usize
pub fn (Arena) reset(arena: Arena) void = trust { ... }
type Stack = { buf: ref void, offset: usize, cap: usize }
Fields
| Name | Type |
|---|
buf | ref void |
offset | usize |
cap | usize |
pub fn (Stack) new(capacity: usize) result[Allocator, AllocError] = trust { ... }
pub fn (Stack) alloc(stack: Stack, size: usize) option[ref void]
pub fn (Stack) save(stack: Stack) usize
pub fn (Stack) restore(stack: Stack, checkpoint: usize) void
pub fn (Stack) free(stack: mut Stack) void = trust { ... }
pub type HeapAllocator = { }
pub fn (HeapAllocator) alloc(_: HeapAllocator, size: usize) option[ref void] = trust { ... }
pub fn (HeapAllocator) free(_: HeapAllocator, ptr: ref void) void = trust { ... }
pub fn (HeapAllocator) realloc(_: HeapAllocator, ptr: ref void, new_size: usize) option[ref void] = trust { ... }
pub fn bump_alloc_unwrap[A: Allocator](ac: A, size: usize) ref void
pub fn alloc_in[A: GeneralAllocator](ac: A, size: usize) option[ref void]
pub fn free_in[A: GeneralAllocator](ac: A, ptr: ref void) void
pub fn realloc_in[A: GeneralAllocator](ac: A, ptr: ref void, new_size: usize) option[ref void]