#include typedef struct { char* startptr; char* endptr; // points beyond last element char* readpos; char* writepos; } ringbuf_t; void ringbuf_init(ringbuf_t* rb, char* buf, int size);