MMgr v2.3.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches
octetus_introitus_exitus - byte verbs over a span

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

Function Documentation

◆ mmgr_byteio_put()

EMBED_HOST_DEVICE void mmgr_byteio_put ( const OctetusCfg * args)

Appends args->byte to args->write_span.

Parameters
[in,out]argsSpan and the byte to append [BORROWS].
Warning
An append past the span's cap is a build failure. It asserts, stores nothing and latches overflow. pos counts the byte either way.

References mmgr_byteio_put().

Referenced by mmgr_byteio_put().

◆ mmgr_byteio_put_be()

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.

Parameters
[in,out]argsSpan, value and byte count [BORROWS].
Note
The value reverses once and then goes out at the widest step the count allows. A count of eight is one store and a count of seven is three.
Warning
An append past the span's cap is a build failure. It asserts, stores nothing and latches overflow. pos advances either way.
args->bytes must be 1 through 8.

References mmgr_byteio_put_be().

Referenced by mmgr_byteio_put_be().

◆ mmgr_byteio_raw()

EMBED_HOST_DEVICE void mmgr_byteio_raw ( const OctetusCfg * args)

Appends args->bytes from args->src to args->write_span as they are.

Parameters
[in,out]argsSpan, source and byte count [BORROWS].
Warning
An append past the span's cap is a build failure. It asserts, stores nothing and latches overflow. pos advances either way.
args->src must be readable for args->bytes, and must not overlap the span's buffer.

References mmgr_byteio_raw().

Referenced by mmgr_byteio_raw().

◆ mmgr_byteio_take_be()

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.

Parameters
[in,out]argsSpan, byte count and where to store the value [BORROWS].
Returns
EMBED_TRUE when the bytes were there, EMBED_FALSE when the span was short.
Note
Reads at the cursor and nowhere else. A codec that leads with a tag advances past it itself.
A read that reaches past the end sets the span's err and leaves the cursor and args->out untouched.
Warning
args->bytes must be 1 through 8.

References mmgr_byteio_take_be().

Referenced by mmgr_byteio_take_be().

◆ mmgr_byteio_rd_str()

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.

Parameters
[in,out]argsSpan, and where to report the run and its length [BORROWS].
Returns
EMBED_TRUE when the length and its run both position within the span.
Note
No copy. args->blob points into the span's own bytes, and so it lives only as long as they do [BORROWS].
The cursor advances past the length and the run together. A caller reading a sequence of these needs to track nothing between them.
A run that reaches past the end leaves the cursor where it started, sets the span's err, and writes nothing through args->blob or args->blob_bytes. The length alone read does not move the cursor either, since a partial read is not a read.

References mmgr_byteio_rd_str().

Referenced by mmgr_byteio_rd_str().

◆ mmgr_byteio_mpint_fixed()

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.

Parameters
[in,out]argsThe integer with its length in args->src and args->bytes, and the field as args->write_span [BORROWS].
Returns
EMBED_TRUE when the integer fits the field, EMBED_FALSE when it does not.
Note
The width test does not count leading zero bytes of the integer. A value with a sign byte still fits a field of its own size.
The field fills whole with no append. On success args->write_span's cursor ends at its cap.
Nothing goes into the field when it returns EMBED_FALSE, but args->write_span's overflow stays set. A span tested later reports the failure too.
Warning
args->src must be readable for args->bytes, and must not overlap args->write_span's buffer.

References mmgr_byteio_mpint_fixed().

Referenced by mmgr_byteio_mpint_fixed().

Variable Documentation

◆ byteio

const OctetusIntroitusExitusNs byteio
static

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

Definition at line 161 of file octetus_introitus_exitus.h.