MMgr v2.3.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches

Asserts MMGR_CARCER_ALIGN is a power of two. More...

#include <locus_carcerum.h>

Data Fields

const char * name
size_t place
embed_atomic_usize in_use
embed_atomic_usize hw

Detailed Description

Asserts MMGR_CARCER_ALIGN is a power of two.

Note
A round of an offset masks off its low bits, which lands on a multiple only for a power of two. Both carcer_round and CARCER_HDR in locus_carcerum.c round that way.

Asserts the storage a pool declaration aligns is on the cell grain.

Note
A cell's words lie at whole grains from the storage's first byte, and they are at their alignment only where that byte does.

One owner of cells: its name, its key, the payload bytes of its cells now on both tiers, and the max it had at once.

Note
The library's storage, positioned at compile time. The owner table is the list of these records that MMGR_OWNERS declares in the program's one translation unit for it. The same declaration defines each owner's identity: a const pointer into the table, which the linker resolves. The owner's module names it on every take, give and growth, as it names a movable cell's entry.
Nothing registers at run time. The pointer's const says only that the holder does not write; the record is MMgr's to write. Every entry refuses NULL in place of an owner, and every take refuses a pointer that is not one of the table's.
The key is the owner's place in the table, counted from 1.
A take adds the cell's payload bytes to in_use and raises hw to it; a give takes the same bytes off. Every count is an atomic word, added to and raised in one step each, and an owner shared between contexts counts exactly.
The bytes counted are the cell's own: the request rounded to a whole word. The take counts them on, the give reads them off the cell's word, and a matched pair returns in_use to where it was.
Every cell carries its owner in the word behind its payload, and comes off that owner as a give drops it. A give or a growth that names another owner fails, and mmgr_carcer_hw_misnamed hears of it.

Definition at line 229 of file locus_carcerum.h.

Field Documentation

◆ name

const char* CellOwner::name

The owner's name, as a reader prints it, unique in the table [BORROWS].

Definition at line 231 of file locus_carcerum.h.

◆ place

size_t CellOwner::place

The owner's place in the table, from 1.

Definition at line 232 of file locus_carcerum.h.

◆ in_use

embed_atomic_usize CellOwner::in_use

Payload bytes of the cells the owner has now.

Definition at line 233 of file locus_carcerum.h.

Referenced by mmgr_owner_in_use().

◆ hw

embed_atomic_usize CellOwner::hw

The highest value of in_use so far.

Definition at line 234 of file locus_carcerum.h.

Referenced by mmgr_owner_hw().


The documentation for this struct was generated from the following file: