whalloc  whalloc_region

The whalloc_region API

Files: whalloc.h, whalloc_region.c

The "region" API is a trivial allocator which manages allocation from a client-defined block of memory. It can only allocate, not deallocate, individual objects.

It looks something like this:

whalloc_region r = whalloc_region_empty;
whalloc_region_init(r, myMemory, sizeOfMyMemory );
void * x = whalloc_region_alloc( &r, sizeOfMyMemory/2 );
...
// To free all items at once:
whalloc_region_free( &r );

Trivia: unlike whalloc_bt and whalloc_ht, this allocator may allocate more than (2^WHALLOC_BITNESS-1) bytes in a single allocation.