A growable byte buffer for building strings and messages, with printf
$ sexc add @ajax/mesh-buf- total 3
- drwxr-xr-x-../
- drwxr-xr-x-Oct 27 05:23v/# 1 version
- drwxr-xr-x-Oct 27 05:23files/# the files of 0.1.0
- latest
- 0.1.0, published Oct 27 05:23 by ajax
- owners
- ajax
- license
- MIT
- dependencies
- @ajax/mesh-check ^0.1.0
- dependents
- @ajax/mesh-args, @ajax/mesh-chan, @ajax/mesh-control, @ajax/mesh-driver, @ajax/mesh-http-relay, @ajax/mesh-infer-request, @ajax/mesh-infer-svc, @ajax/mesh-infer-wire, @ajax/mesh-inferd, @ajax/mesh-load-host, @ajax/mesh-load-proc, @ajax/mesh-load-prog, @ajax/mesh-load-text, @ajax/mesh-nic, @ajax/mesh-publish, @ajax/mesh-reply, @ajax/mesh-rsfmt, @ajax/mesh-samplers, @ajax/mesh-shared, @ajax/mesh-snapshot, @ajax/mesh-views, @ajax/meshd
- keywords
- mesh alphaos string buffer
- homepage
- https://github.com/thomasdavis/alpha-c-mesh/tree/main/packages/mesh-buf
- repository
- https://github.com/thomasdavis/alpha-c-mesh
1# @ajax/mesh-buf 2 3A growable byte buffer for building strings and messages: append bytes, text, `printf` output and 4little-endian words; the bytes are always NUL-terminated, so a buffer holding text is a C string. 5Allocation failure aborts (`mesh_xmalloc` and friends too): meshd never goes on with half a message. 6 7```c 8#include "mesh/buf.h" 9mesh_buf b = MESH_BUF_INIT; 10mesh_buf_printf(&b, "ok %u us", 412u); 11char *s = mesh_buf_take(&b); /* free(s) */ 12``` 13 14## Ported from 15 16[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT): what Rust's `String` 17and `Vec<u8>` (with `format!` and `extend`) do throughout `crates/mesh-host`. There is no single Rust 18item; every daemon package builds its replies with it. 19 20## Tests 21 22- `tests/buf.c`: appends, growth, `printf`, little-endian words, take, truncate. 23 24## Licence 25 26MIT. See the repository's LICENSE.