Skip to content

Zero-allocation ring-buffer library

License

Notifications You must be signed in to change notification settings

rikvdh/zringbuf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jul 16, 2020
e096893 · Jul 16, 2020

History

3 Commits
Jun 14, 2020
Jun 14, 2020
Jun 14, 2020
Jun 14, 2020
Jun 14, 2020
Jul 16, 2020
Jun 14, 2020
Jul 16, 2020
Jun 14, 2020

Repository files navigation

zringbuf

Build Status

Zero-Allocation ring-buffer in C

Installation

With clib:

clib install rikvdh/zringbuf

Example

#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;
}