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

Spans over a caller's buffer, the two span types, and the spat dispatch table. More...

#include "mmgr.h"

Go to the source code of this file.

Data Structures

struct  mmgr_span
 A buffer under fill: its bytes, how far the writer went, and whether it ran out. More...
struct  mmgr_cspan
 A buffer under read: its bytes, how far the reader went, and whether it ran out. More...
struct  SpatiumCfg
 Arguments for every spat call, where each call reads only the members it needs. More...
struct  SpatiumNs
 Type of the spat dispatch table. More...

Functions

EMBED_HOST_DEVICE mmgr_span mmgr_spat_from (const SpatiumCfg *args)
 Builds a fill span over args->buf, with pos at 0 and overflow clear.
EMBED_HOST_DEVICE mmgr_cspan mmgr_spat_cfrom (const SpatiumCfg *args)
 Builds a read span over args->cbuf, with pos at 0 and err clear.
EMBED_HOST_DEVICE embed_bool mmgr_spat_ok (const SpatiumCfg *args)
 Returns whether args->span has storage and has not overflowed.
EMBED_HOST_DEVICE embed_bool mmgr_spat_cok (const SpatiumCfg *args)
 Returns whether args->cspan has storage and recorded no error.
EMBED_HOST_DEVICE embed_bool mmgr_spat_has_storage (const SpatiumCfg *args)
 Returns whether args->span covers any bytes at all.
EMBED_HOST_DEVICE void mmgr_spat_reset (const SpatiumCfg *args)
 Returns the span at args->at to its start and clears its overflow.
EMBED_HOST_DEVICE mmgr_span mmgr_spat_after (const SpatiumCfg *args)
 Returns the span that begins args->count bytes into args->span.
EMBED_HOST_DEVICE mmgr_span mmgr_spat_first (const SpatiumCfg *args)
 Returns the span that covers only the first args->count bytes of args->span.
EMBED_HOST_DEVICE mmgr_cspan mmgr_spat_produced (const SpatiumCfg *args)
 Returns a read span over everything written into args->span.
EMBED_HOST_DEVICE mmgr_cspan mmgr_spat_read (const SpatiumCfg *args)
 Returns a read span over the first args->count bytes written into args->span.

Variables

static const SpatiumNs spat
 Dispatch table instance named spat, with each member set to its mmgr_spat_ function.

Detailed Description

Spans over a caller's buffer, the two span types, and the spat dispatch table.

Author
dstroy0 (Douglas Quigg) dquig.nosp@m.g123.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Date
2026-08-29
Note
A span is a region and a cursor into it, with a sticky flag that latches once a walk runs past the end. It carries no storage of its own.
The entries take an argument pack, as every other module's do. A span still travels by value inside that pack. SpatiumCfg holds one and does not point at one. A walk cannot change the span it received.
There are two span types and not one. Writes go through mmgr_span and it latches overflow. Reads come from mmgr_cspan and it latches err. Their extents have the names cap and len, and so one in the place of the other is a compile error.
The sticky flag is the reason to pass a span at all. A caller may walk one through several steps and test once at the end and not after each.
overflow and err do not mean the same type of thing. A fill span overruns only when what a writer emits has the wrong size against its buffer. Both of those are before the build, and so overflow marks a wrong program. A read span runs out because whatever sent the bytes sent fewer, which is a runtime fact and nothing built wrong.

Definition in file spatium.h.