std1.0.0-beta-7 SafeC docs

Module collections::node_pool

#include <std/collections/node_pool.h> source

NodePool<N>: per-container node allocator

Node-based containers (List, BST) take their nodes from a NodePool instead of calling alloc() per node. Nodes are carved from chunks that double in size (8, 16, ... 1024 nodes), recycled through a free list when removed, and released all at once by free_all(). Compared with one alloc() per node this drops the per-block allocator header and size- class padding (a 24-byte node used to occupy a 48-byte heap chunk), and a container's free() costs O(chunks) instead of O(nodes).

A removed node's memory stays owned by the pool and is reused by the next take(): references into a removed element dangle exactly as they would with dealloc(), they just don't fault.

Structs

NodePool

Functions

memcpysize_t: 32-bit on wasm32 / 32-bit targets

Macros

NODE_POOL_FIRST_CHUNK
NODE_POOL_MAX_CHUNK
NODE_POOL_CHUNK_HDRkeeps nodes 16-byte aligned