Zero-Allocation ring-buffer in C
With clib:
clib install rikvdh/zringbuf
#include "zringbuf.h"
#include <assert.h>
// Create ring-buffer called 'buf' with size of 100 bytes
ZRINGBUF_DECL(buf, 100)
int main(int argc, char **argv)
{
zringbuf_queue(&buf, 'a');
zringbuf_queue_arr(&buf, "bcd", 3);
assert(4 == zringbuf_size_used(&buf));
char ch;
assert(true == zringbuf_dequeue(&buf, &ch));
assert(ch == 'a');
return 0;
}