# HG changeset patch # User Matti Hamalainen # Date 1307759769 -10800 # Node ID 21528fe535fbe4c8675d8b02cd2873e2b965e9d4 # Parent 6918c46015d0834960d293466137b3cdeeba53d2 Don't use void pointers in the ringbuffer implementation. diff -r 6918c46015d0 -r 21528fe535fb th_util.c --- a/th_util.c Sat Jun 11 05:10:41 2011 +0300 +++ b/th_util.c Sat Jun 11 05:36:09 2011 +0300 @@ -403,7 +403,7 @@ { qringbuf_t *res = th_calloc(1, sizeof(qringbuf_t)); - res->data = (void **) th_malloc(size * sizeof(void *)); + res->data = (char **) th_calloc(size, sizeof(char *)); res->size = size; res->n = 0; res->deallocator = mdeallocator; @@ -414,9 +414,13 @@ BOOL th_ringbuf_grow(qringbuf_t *buf, const size_t n) { - buf->size += n; - buf->data = (void **) th_realloc(buf->data, buf->size * sizeof(void *)); - return (buf->data != NULL); + buf->data = (char **) th_realloc(buf->data, (buf->size + n) * sizeof(char *)); + if (buf->data != NULL) { + memset(buf->data + buf->size, 0, sizeof(char *) * n); + buf->size += n; + return TRUE; + } else + return FALSE; } diff -r 6918c46015d0 -r 21528fe535fb th_util.h --- a/th_util.h Sat Jun 11 05:10:41 2011 +0300 +++ b/th_util.h Sat Jun 11 05:36:09 2011 +0300 @@ -114,7 +114,7 @@ /* Ringbuffer implementation */ typedef struct { - void **data; + char **data; int n, size; void (*deallocator)(void *); } qringbuf_t;