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

Byte verbs that append into a caller's span or read out of it. More...

#include "spatium/spatium.h"
#include "mmgr.h"

Go to the source code of this file.

Data Structures

struct  OctetusCfg
 Arguments for the byteio calls, where each call reads only the members it needs. More...
struct  OctetusIntroitusExitusNs
 Type of the byteio dispatch table. More...

Functions

EMBED_HOST_DEVICE void mmgr_byteio_put (const OctetusCfg *args)
 Appends args->byte to args->write_span.
EMBED_HOST_DEVICE void mmgr_byteio_put_be (const OctetusCfg *args)
 Appends the low args->bytes of args->value to args->write_span, most significant byte first.
EMBED_HOST_DEVICE void mmgr_byteio_raw (const OctetusCfg *args)
 Appends args->bytes from args->src to args->write_span as they are.
EMBED_HOST_DEVICE embed_bool mmgr_byteio_take_be (const OctetusCfg *args)
 Reads a big endian value of args->bytes at args->read_span's cursor and advances past it.
EMBED_HOST_DEVICE embed_bool mmgr_byteio_rd_str (const OctetusCfg *args)
 Reads a big endian 32-bit length at args->read_span's cursor, then points args->blob at the run behind it.
EMBED_HOST_DEVICE embed_bool mmgr_byteio_mpint_fixed (const OctetusCfg *args)
 Right-aligns the big endian integer at args->src into args->write_span's whole buffer, with a zero fill ahead of it.

Variables

static const OctetusIntroitusExitusNs byteio
 Dispatch table instance named byteio, with each member set to its mmgr_byteio_ function.

Detailed Description

Byte verbs that append into a caller's span or read out of it.

Author
dstroy0 (Douglas Quigg) dquig.nosp@m.g123.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Date
2026-08-29
Note
These act on a caller's span and hold nothing of their own. The span carries the cursor and the sticky flag. A caller may append a whole message and test once at the end.
mmgr_byteio_put, mmgr_byteio_put_be and mmgr_byteio_raw return nothing. What a writer emits and how big its buffer is are both fixed before the build. So a write past the end means the program is wrong. Those three assert, store nothing, and latch overflow to retain a wrong program off the end. None of that leaves a caller anything to act on.
mmgr_byteio_take_be and mmgr_byteio_rd_str answer EMBED_FALSE when the bytes are not there, set the read span's err, and leave the cursor and the output where they were. A reader takes whatever arrives. A short read is a runtime fact and not a build failure. The cursor does not advance on failure, because a caller that retains reading still needs it to mean something.
mmgr_byteio_mpint_fixed is neither of those. It writes a whole field and does not append, and answers whether the integer fit, and so its own declaration carries the contract.
Whole values move a word at a time. The big endian entries reverse once and then store or load at the widest step the count allows, and walk no bytes.

Definition in file octetus_introitus_exitus.h.