mem.allocator
Allocation interface and the interpreter-backed heap allocator.
All modules · Writing docstrings
Allocator
Section titled “Allocator”type AllocatorAllocate, grow, and release raw storage measured in value slots.
Allocator.make
Section titled “Allocator.make”func make(self, cap: Int): RawPtrAllocate cap slots.
Allocator.grow
Section titled “Allocator.grow”func grow(self, raw: RawPtr, old_cap: Int, new_cap: Int): RawPtrMove old_cap slots into a new allocation and release the old one.
Allocator.free
Section titled “Allocator.free”func free(self, raw: RawPtr)Release a live allocation.
HeapAllocator
Section titled “HeapAllocator”kind HeapAllocatorAn allocator implemented with the interpreter’s raw memory intrinsics.
HeapAllocator as Allocator
Section titled “HeapAllocator as Allocator”impl HeapAllocator as AllocatorHeapAllocator as Allocator.make
Section titled “HeapAllocator as Allocator.make”func make(self, cap: Int): RawPtrAllocate cap value slots through mem.alloc.
HeapAllocator as Allocator.grow
Section titled “HeapAllocator as Allocator.grow”func grow(self, raw: RawPtr, old_cap: Int, new_cap: Int): RawPtrAllocate new storage, copy old_cap slots, and free raw. Requires new_cap >= old_cap.
HeapAllocator as Allocator.free
Section titled “HeapAllocator as Allocator.free”func free(self, raw: RawPtr)Free the allocation through mem.free; later access to the handle is invalid.
let heap = HeapAllocator {}The shared heap allocator value. Import with import mem.{heap}.