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

A buffer being filled: its bytes, how far the writer has gone, and whether it ran out. More...

#include <spatium.h>

Data Fields

uint8_t * buf
size_t cap
size_t pos
embed_bool overflow

Detailed Description

A buffer being filled: its bytes, how far the writer has gone, and whether it ran out.

Note
Returned by value. This module keeps no span of its own.
overflow is sticky. Once a write has run past cap it stays set, and only mmgr_spat_reset clears it.
Reaching it at all is a build failure, and so it is read to find out that something is wrong and not to decide what to do next. It latches so that a wrong program stops writing instead of walking off the end, and so that one test after a run of appends catches it.
Warning
buf points at the caller's storage, which must outlive every use of the span [BORROWS].

Definition at line 46 of file spatium.h.

Field Documentation

◆ buf

uint8_t* mmgr_span::buf

The buffer the span covers [BORROWS].

Definition at line 48 of file spatium.h.

◆ cap

size_t mmgr_span::cap

Bytes in buf.

Definition at line 49 of file spatium.h.

◆ pos

size_t mmgr_span::pos

Bytes written so far, which mmgr_spat_from sets to 0.

Definition at line 50 of file spatium.h.

◆ overflow

embed_bool mmgr_span::overflow

Set once a write has run past cap, and cleared only by mmgr_spat_reset.

Definition at line 51 of file spatium.h.


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