← alloc

alloc/lib.kur

//! 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.
use package::{arena, buffer, collections, fmt, heap, owned};
export arena;
export buffer;
export collections;
export fmt;
export heap;
export owned;