Purpose: Declare a prison site, allocate from both tiers of one of its cellblocks, and give each cell back. Scope: include/mmgr.h, src/locus_carcerum/locus_carcerum.h, src/locus_carcerum/locus_carcerum.c Author: dstroy0 (Douglas Quigg) dquig.nosp@m.g123.nosp@m.@gmai.nosp@m.l.co.nosp@m.m Date: 2026-08-29
The first two lines declare the storage and its alignment. The third dresses each pool as a cellblock and emits the site. All three are declarations and none is a call. They emit only data with initial values, and nothing runs at startup. A cellblock's first byte is the address of the pool under it, and the linker resolves it.
You reach a cellblock by the name of its pool, and prison.work is the cellblock over work. Pool names are for one region each, and no two cellblocks anywhere in a translation unit can share a name.
MMGR_MINIMUM_SECURITY and MMGR_MAXIMUM_SECURITY pick which guards hold a cellblock. The declaration settles the choice: "The warden is const, so nothing after the declaration can change the level a cellblock runs at" (src/locus_carcerum/locus_carcerum.h:24). The two guard types declare the same sixteen entries under different behavior. prison.keys has no unzeroed release to reach for, and prison.work has no release that zeroes (src/locus_carcerum/locus_carcerum.h:436, src/locus_carcerum/locus_carcerum.h:477).
Every take names the owner that the cellblock counts its bytes to. That owner is a const pointer into the program's owner table, which MMGR_OWNERS declares once, as data, beside the pools. Both return the first byte of a cell [RETURNS OWNERSHIP]. Either tier takes it back through prison.work.persistent_buf_release: the cell's offset says which tier it lies in.
The two tiers grow toward each other out of the same gap. A request that neither the gap nor a free run of the persistent tier can meet returns NULL. A bump the gap cannot meet records its bytes as the tier's overrun, and the exclusive path that follows moves no boundary either.
"The public entries are English and the internals are Latin, this filename included" (src/locus_carcerum/locus_carcerum.h:25). The Latin, decoded decodes the Latin you will meet inside.
Interim is persist with its base at the top. You give each cell back by itself, in any order.
This is the pattern for any bounded operation: take on the way in, release on the way out. The interim cost of the operation is zero afterwards no matter how many takes it made. A cell released below the top stays free in the tier. It stays until the top comes back over it or a take the gap cannot meet merges it.
buf_available is not a release. It reports the gap still between the two ends. It is what you log when a take returns NULL and you want to know by how much you missed.
Do not compute the size on paper. Measure it.
Build the checks environment, run your real workload, and read those. checks compiles in the library's checks and selects the MMGR_ASSERT that traps. A precondition you broke fails loudly and is not a no-op:
Then size the region to the peak plus whatever margin your failure policy wants. Why there is no malloc argues why this bill is worth its cost.
Every exit path either returns before it takes anything or gives back what it took.
Next: Region, pool, span, ring for how pools, spans and rings sit on top of this.