std1.0.0-beta-7 SafeC docs

Module heap

#include <std/heap.h> source

Global Freestanding Heap Unified heap interface backed by:

Freestanding: static HEAP_SIZE-byte buffer managed by TLSF (O(1), real-time-safe).
Hosted:       thin malloc/free/realloc wrappers.

Override buffer size with -DHEAP_SIZE=<bytes> at compile time.

Functions

heap_initno-op
heap_allocAllocate size bytes from the global heap. Returns NULL on failure.
heap_freeFree a block returned by heap_alloc() or heap_realloc().
heap_reallocResize an allocation. Copies up to min(old_size, new_size) bytes. Returns NULL on failure; original block is NOT freed in that case.
heap_capacityReturn total heap capacity in bytes. In hosted mode returns 0 (unbounded).

Macros

HEAP_SIZE1 MiB default