# stack-arena
A fast, stack-like arena allocator inspired by GNU obstack, implemented in Rust.
## Features
- Efficient allocation of variable-sized objects with minimal overhead.
- Objects are allocated in contiguous memory chunks.
- Stack-like (LIFO) allocation and deallocation.
- No per-object deallocation: free all objects at once or roll back to a checkpoint.
- Suitable for parsers, interpreters, and other high-performance scenarios.
## Usage
Add to your `Cargo.toml`:
```toml
[dependencies]
stack-arena = "0.1"
```
Example:
```rust
use stack_arena::SimpleObstack;
fn main() {
let mut ob = SimpleObstack::<1024, u8>::new();
ob.grow(b"hello");
let ptr = ob.finish();
// Use ptr...
}
```
## Safety
- All returned pointers or references are valid as long as the arena is not cleared or reset.
- Objects are always stored contiguously in a single chunk.
## License
MIT
## Acknowledgements
Inspired by [GNU obstack](https://www.gnu.org/software/gnulib/manual/html_node/obstack.html).