Scheme for TinyMUX 2.4 and prior as well as other related codebases:
A B C D E ...
^ ^
| |
char *buff---/ |
char **bufc------------/
To null-terminate: *(*bufc) = '\0';
To determine length: size_t n = *bufc - buff
Scheme for TinyMUX 2.6 reference counting of global registers:
struct reg_ref
{
int refcount; // How many references exist for this value?
lbuf_ref *lbuf; // Which lbuf is holding the value?
// Length and null-terminated string stored in the above lbuf.
//
size_t reg_len;
char *reg_ptr;
};
struct lbuf_ref
{
int refcount; // How many references are using this lbuf?
char *lbuf_ptr; // LBUF_SIZE-ed buffer allocated with alloc_lbuf().
};