tiny.bumpalo
Overview · API · Code relationships · Verification · Audit
Overview
An allocator that hands out memory by moving one cursor and releases every allocation at once is a bump arena. A caller reaches for it when many small objects share one lifetime. The arena takes its memory from an allocator the caller supplies, the backing allocator.
The arena holds its memory in a contiguous block it owns, a chunk. Each chunk holds its own header, its capacity, and the offset that separates handed-out bytes from free bytes, the cursor. Each chunk points at the chunk before it, so the arena is a chain of chunks with the newest at the head. An allocation inside the active chunk moves the cursor by the requested size and returns those bytes, and the arena stores no header of its own beside the object. When the active chunk has too little room, the arena asks the backing allocator for a new chunk, usually twice the size of the last one, and makes it the active one.
A caller can set an optional cap on the bytes the arena may take from the backing allocator, the backing data capacity limit. A request larger than the remaining cap fails, which leaves the arena the size it was. initBuffer takes a buffer from the caller and links it as a chunk the arena borrows, the caller storage, and the arena still grows through the backing allocator once that buffer fills.
reset releases every allocation at once. Which chunks a reset call keeps depends on the reset mode: free_all, retain_current, retain_capacity, or retain_with_limit. reset answers false when a retaining mode cannot keep the capacity it was asked for, which happens when a lowered backing data capacity limit cannot cover a replacement chunk. Every pointer into the arena is dead after a reset, and the arena runs no cleanup code for the objects that lived there, so the caller finishes with those pointers first.
Definitions
Actions
Public operations.
Types and contracts
Public types and contracts.
Values and defaults
Public values and defaults.
Code relationships
Direct static dependencies extracted from parsed source by semantic graph analysis.
Uses: tiny.bench, tiny.hypothesis, tiny.sql, tiny.sys
Used by: alloc_fixed, tiny.alloc, tiny.choir, tiny.gpalloc, tiny.hypothesis, tiny.smg, tiny.sql, tiny.stabilizer, tiny.tracy
Verification
No verification records are cataloged for this module in this build.
Audit
| Evidence | Value |
|---|---|
| Source | lib/bumpalo/src/root.zig |
| Definitions | 0 of 7 documented |
| Members | 0 of 0 documented |
| Public names | 7 API, 7 indexed |
| Version | 26.7.0 |
| Revision | daab053ee433 |
| Unresolved targets | 1 |