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

array_from_stack
array_from_stack :: macro ($T: type_expr, size: u32) -> [] T

Allocates memory from the stack to form a slice of T with length size.

DO NOT USE THIS IN A LOOP! You cannot free memory allocated off the stack.

as_allocator
as_allocator :: macro (a: Allocator) -> unknown
as_allocator :: (rs: &Arena) -> Allocator
as_allocator :: (fa_data: &FixedAllocator) -> Allocator
as_allocator :: (rs: &RingState) -> Allocator
as_allocator :: (pool: &PoolAllocator($Elem)) -> Allocator
as_allocator :: (hs: &GCState) -> Allocator
as_allocator :: (memdebug: &MemDebugState) -> Allocator
as_allocator :: (atomic: &AtomicAllocator) -> Allocator

Overloaded procedure for converting something to an Allocator.

clear_temp_allocator
clear_temp_allocator :: () -> void

Resets the temporary allocator, effectively freeing all allocations made in the temporary allocator.

copy_closure
copy_closure :: (f: $F, a: Allocator) -> F
    where type_is_function(F)

Copies the internal closure data of a function to the provided allocator, and returns the new closed function.

from_stack
from_stack :: macro (size: u32) -> rawptr

Allocates memory from the stack. This is similar to alloca in C.

DO NOT USE THIS IN A LOOP! You cannot free memory allocated off the stack.

init_temp_allocator
init_temp_allocator :: () -> void

Initializes the thread-local temporary allocator.

You do not need to call this. It is called automatically on thread initialization.

on_heap
on_heap :: macro (v: $V) -> &V

Moves a value on to the heap. Useful for cases like this in

f :: () -> &Foo {
    return alloc.on_heap(Foo.{
        name = "...",
        age  = 42
    });
}
on_temp
on_temp :: macro (v: $V) -> &V

Like alloc.on_heap, but allocates on the temporary allocator.