Mercurial > hg > th-libs
diff th_util.h @ 23:a4f894105953
Add ringbuffer implementation.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 09 Jun 2011 17:33:18 +0300 |
parents | bbb243eba688 |
children | 06a72c643460 |
line wrap: on
line diff
--- a/th_util.h Sun May 22 02:11:05 2011 +0300 +++ b/th_util.h Thu Jun 09 17:33:18 2011 +0300 @@ -111,6 +111,20 @@ qlist_t * th_llist_find_func(qlist_t *list, const void *userdata, int (compare)(const void *, const void *)); +/* Ringbuffer implementation + */ +typedef struct { + void **data; + int n, size; + void (*deallocator)(void *); +} qringbuf_t; + +qringbuf_t * th_ringbuf_new(const size_t size, void (*mdeallocator)(void *)); +BOOL th_ringbuf_grow(qringbuf_t *buf, const size_t n); +void th_ringbuf_free(qringbuf_t *buf); +void th_ringbuf_add(qringbuf_t *buf, void *ptr); + + #ifdef __cplusplus } #endif