alloc_fixed.FixedBuffer
Internal implementation documentation
Defined in alloc_fixed.
This owner allocates from a byte slice the caller already owns, with no allocator behind it, providing a fixed-capacity buffer allocator over that slice.
Source
Source: lib/alloc/fixed/src/fixed.zig:37
zig
/// This owner allocates from a byte slice the caller already owns, with no/// allocator behind it, providing a fixed-capacity buffer allocator over that/// slice. With observation left off (`-Dobserve-allocations=false`), it is/// `std.heap.FixedBufferAllocator` itself. With observation compiled in/// (`-Dobserve-allocations=true`), it is `ObservedFixedBuffer`, a wrapper/// holding a `std.heap.FixedBufferAllocator` and a producer identity.////// ### Owner stability and address requirements/// The owner struct stays alive and at one memory address while a borrowed/// allocator handle is in use. One owner serves one buffer, and the caller/// takes no copy of it to act as a second allocator over that same storage.////// ### Memory operations and reclamation/// Memory is cut in order from the start of the buffer up to the byte offset/// the allocations have reached inside the buffer, the *bump frontier*. Freeing/// or shrinking the most recent allocation lowers the frontier. Freeing an/// earlier allocation leaves its space taken until `reset()` rewinds the/// frontier. Calling `reset()` rewinds the frontier to zero and leaves every/// active allocation invalid, so the space can be used again.////// ### Concurrency and thread safety/// The ordinary `allocator()` handle needs the caller to serialize access. The/// `threadSafeAllocator()` handle advances the frontier with lock-free/// compare-and-swap inside the standard library allocator. With observation on,/// the instrumented callbacks and the observation bookkeeping carry no such/// guarantee and handle their own concurrency. Calling `used()` or reading the/// owner's fields while thread-safe operations run leaves a data race. A caller/// keeps concurrent calls to `allocator()` and to `threadSafeAllocator()`/// apart, and leaves `reset()` alone while thread-safe operations may be/// running. Calling `Tracked.status()` needs the caller's own serialization.pub const FixedBuffer = if (observe.enabled) ObservedFixedBufferelse std.heap.FixedBufferAllocator;Source: lib/alloc/fixed/src/root.zig:421
zig
/// `FixedBuffer` is a fixed-capacity bump allocator that cuts allocations from/// a caller-owned byte slice with no allocator behind it. With allocation/// observation compiled in (`-Dobserve-allocations=true`) it resolves to/// `ObservedFixedBuffer`, and with observation off it is/// `std.heap.FixedBufferAllocator`.pub const FixedBuffer = fixed.FixedBuffer;Audit
| Definitions | 1 |
|---|---|
| Public names | 1 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |