Skip to content

Memory

Source: std/mem.mw.

Thin, stable names over the allocator in heap.mw and the primitives in raw.mw. Every allocating function has a matching free.

Thin, stable names over the libc-free allocator (std/heap.mw) and the memory primitives (std/raw.mw).

struct Arena {
buffer: *u8;
capacity: i64;
offset: i64;
}
fn alloc(size: i64) -> *u8
fn realloc(ptr: *u8, new_size: i64) -> *u8
fn dealloc(ptr: *u8)
fn mem_copy(dest: *u8, src: *u8, count: i64)
fn mem_zero(dest: *u8, count: i64)
fn arena_new(capacity: i64) -> *Arena
fn arena_alloc(a: *Arena, size: i64) -> *u8
fn arena_reset(a: *Arena)
fn arena_free(a: *Arena)