Fixed-Size Arena Allocator
A minimal no-std, no-alloc arena allocator with fixed capacity.
Features
- Fixed-size: All memory pre-allocated at compile time
- No-std, no-alloc: Works in embedded environments with no heap
- Generic: Works with any
Copytype - Interior mutability: Safe access via
Cell(no runtime borrow checking overhead) - O(1) allocation: Free-list based allocation and deallocation
- Mark-and-sweep GC: Trait-based garbage collection via [
Trace] - Zero dependencies: Only uses
core::cell::Cell
Module Organization
The arena allocator is organized into the following modules:
- [
types] - Core types:ArenaIndex,ArenaError,ArenaResult - [
arena] - MainArenastruct and core operations - [
traits] - Extension traits:ArenaDelete,ArenaCopy,Trace - [
gc] - Garbage collection implementation - [
iter] - Iterator support - [
stats] - Statistics types:ArenaStats,GcStats
Example
use ;
let arena: = new;
// Allocate nodes
let left = arena.alloc.unwrap;
let right = arena.alloc.unwrap;
let root = arena.alloc.unwrap;
// Access nodes
if let Branch = arena.get.unwrap
// Free when done
arena.free.unwrap;