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

Bit writer state, its arguments, and the bitio dispatch table. More...

#include "mmgr.h"

Go to the source code of this file.

Data Structures

struct  mmgr_bitor
 Bit writer state: the buffer, how much went out, and the partial byte. More...
struct  BitorumCfg
 Arguments for the bitor calls, where each call reads only the members it needs. More...
struct  BitorumIntroitusExitusNs
 Type of the bitio dispatch table. More...

Functions

EMBED_HOST_DEVICE mmgr_bitor mmgr_bitor_init (const BitorumCfg *args)
 Builds a bit writer over args->out with capacity args->cap.
EMBED_HOST_DEVICE void mmgr_bitor_put (const BitorumCfg *args)
 Appends the low args->bit_count bits of args->val to args->writer.
EMBED_HOST_DEVICE void mmgr_bitor_align (const BitorumCfg *args)
 Writes the partial byte the writer still holds, padded with zeros above its bits.

Variables

static const BitorumIntroitusExitusNs bitio
 Dispatch table instance named bitio, with each member set to its mmgr_bitor_ function.

Detailed Description

Bit writer state, its arguments, and the bitio 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
Packs bit fields of any width into a byte buffer and no bit ever crosses a call. The writer holds the partial byte. A caller states widths and values and never does its own shifts or masks.
The writer is a value the caller owns and not state this module retains. Two streams are two writers, and neither module state nor a lock comes into it.
Warning
put writes whole bytes only. So bits that do not fill one stay in the writer's residue and align puts that last partial byte out. A stream whose length is not a multiple of eight and that never calls align ends one byte short. No flag rises and nothing shows at the call.

Definition in file bitorum_introitus_exitus.h.