C+
Packages · v0.0.13

arena

A growable, multi-chunk bump-pointer arena for "allocate many, free all" workloads: parsers, compilers, request-scoped allocations. Arena::new(chunk_size) rounds up to a chosen minimum; allocations stride through chunks, growing as needed. reset() (and the automatic Drop) returns every chunk to the heap.

The out-of-memory convention: raw APIs return 0 as *u8, while parallel _opt variants return Option[*u8].

import "arena/arena" as arena;

let mut a: arena::Arena = arena::Arena::new(4096 as usize);
let p: *u8 = unsafe { a.alloc_bytes(64 as usize) };
let s: str = a.alloc_str("hello");
// dropping `a` frees every chunk

For an arena that never touches the heap, see static-arena.