MMgr v1.0.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches
CellOwner Struct Reference

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
An offset is rounded by masking off its low bits, which lands on a multiple only for a power of two. carcer_round and CARCER_HDR in locus_carcerum.c both round that way.

Asserts the storage a pool declaration aligns is aligned to the cell grain.

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

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

Note
The library's storage, laid at compile time. The owner table is the list of these records MMGR_OWNERS declares in the program's one translation unit for it, and the same declaration defines each owner's identity: a const pointer into the table the linker resolves, which the owner's module names on every take, give and growth, as a movable cell's entry is named. 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, counted on the take and read off the cell's word on the give, and a matched pair returns in_use to where it stood.
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 naming another owner is refused and told through mmgr_carcer_hw_misnamed.

Definition at line 150 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 152 of file locus_carcerum.h.

◆ place

size_t CellOwner::place

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

Definition at line 153 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 154 of file locus_carcerum.h.

Referenced by mmgr_owner_in_use().

◆ hw

embed_atomic_usize CellOwner::hw

Running maximum of in_use.

Definition at line 155 of file locus_carcerum.h.

Referenced by mmgr_owner_hw().


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