8 /* simple ring buffer */
10 typedef struct _ringbuf
{
11 size_t n
; /* allocd size */
12 size_t u
; /* used space */
13 size_t i
; /* input pos */
14 size_t o
; /* output pos */
15 char d
[]; /* C99 flexible array member */
18 ringbuf
*ringbuf_new(size_t sz
);
19 int ringbuf_put(ringbuf
*r
, const void *data
, size_t len
);
20 size_t ringbuf_get_pending_size(ringbuf
*r
);
21 size_t ringbuf_get_next_chunk(ringbuf
*r
, char **data
);
22 void ringbuf_mark_consumed(ringbuf
*r
, size_t len
);
23 void ringbuf_free(ringbuf
*r
);
24 void ringbuf_clear(ringbuf
*r
);
26 #endif /* _RINGBUF_H_ */