Packages

builtin
cbindgen
core
core.alloc
core.alloc.arena
core.alloc.atomic
core.alloc.fixed
core.alloc.gc
core.alloc.heap
core.alloc.log
core.alloc.memdebug
core.alloc.pool
core.alloc.ring
core.arg_parse
core.array
core.avl_tree
core.bucket_array
core.conv
core.doc
core.encoding
core.encoding.base64
core.encoding.csv
core.encoding.hex
core.encoding.json
core.encoding.kdl
core.encoding.osad
core.encoding.utf8
core.hash
core.hash.md5
core.hash.sha1
core.hash.sha256
core.heap
core.intrinsics
core.intrinsics.atomics
core.intrinsics.onyx
core.intrinsics.types
core.intrinsics.wasm
core.io
core.io.binary
core.iter
core.js
core.list
core.map
core.math
core.memory
core.misc
core.net
core.os
core.random
core.set
core.slice
core.string
core.sync
core.test
core.thread
core.time
main
runtime
runtime.info
runtime.platform
runtime.vars
simd

package core.alloc.fixed

This allocator is very simple. It is simply a bump allocator from a fixed size buffer. It cannot free or resize, and will return null when it has used all memory in the buffer given to it.

This kind of allocator is useful for temporary string building or similar circumstances, where you know that the needed memory size will not be exceeded, but you don't what to deal with potential slowness of a general heap allocator. By using this allocator, you can continue to use the same code that does allocations like normal, but can get the speed increase of a simple allocation strategy.

FixedAllocator
FixedAllocator :: struct {
    buffer: [] u8;
    end: u32;
}
fixed_allocator_proc
fixed_allocator_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr
make
make :: (buffer: [] u8) -> FixedAllocator
make_allocator
make_allocator :: (fa_data: &FixedAllocator) -> Allocator
reset
reset :: (data: &FixedAllocator) -> void