The allocator library: owned memory, byte buffers, formatting and collections. Needs malloc/realloc/free/abort, from libc or the program.
Running out of memory aborts the program: every constructor and every operation that grows a container (Buffer!::new, push, insert, the arenas, ...) stops it with abort when malloc or realloc fails, and none of them returns an error for it. A program that can recover makes its containers with the fallible constructors, which return heap::AllocError instead: heap::Storage::try_alloc/try_grow, owned::Owned!::try_new, buffer::Buffer!::try_with_capacity, collections::vec::Vec!::try_new and OwnedVec!::try_new, and collections::hashmap::HashMap!::try_new and OwnedMap!::try_new. A container made so still aborts if it later fails to grow.
The collections that own their elements (collections::vec::Vec! and OwnedVec!, collections::hashmap::HashMap! and OwnedMap!) free and empty by one rule: a name ending in _with takes a callback and hands it every element, so it serves linear elements, and the bare name takes none and needs Copy elements. destroy_with(f) and destroy() free the collection; clear_with(f) and clear() empty it and keep its room. Buffer!::destroy() and the arenas' destroy are bare forms too.
Modules
arena | Bump allocation for Copy values that share one lifetime and access brand. |
buffer | Growable byte buffers with explicit ownership and initialized length. |
collections | Owning and arena-backed collections. |
fmt | Formatting adapters for owning byte buffers. |
heap | Raw heap allocation and checked size arithmetic. |
owned | Heap ownership and the records used to open and close memory regions. |