# HG changeset patch # User Matti Hamalainen # Date 1307785977 -10800 # Node ID 06a72c643460efb07daf0bb6778ff2b151355cd9 # Parent 7e0a2a125830b1ec88dd51256044ef7093593b01 Sync. diff -r 7e0a2a125830 -r 06a72c643460 th_util.c --- a/th_util.c Sat Jun 11 05:05:22 2011 +0300 +++ b/th_util.c Sat Jun 11 12:52:57 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; } @@ -424,7 +428,7 @@ { int i; - for (i = 0; i < buf->n; i++) + for (i = 0; i < buf->size; i++) if (buf->data[i] != NULL) buf->deallocator(buf->data[i]); diff -r 7e0a2a125830 -r 06a72c643460 th_util.h --- a/th_util.h Sat Jun 11 05:05:22 2011 +0300 +++ b/th_util.h Sat Jun 11 12:52:57 2011 +0300 @@ -114,7 +114,7 @@ /* Ringbuffer implementation */ typedef struct { - void **data; + char **data; int n, size; void (*deallocator)(void *); } qringbuf_t;