changeset 629:b695eb769e30

Change ringbuffer data type from (char *) to (void *).
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 17 Jan 2020 19:32:13 +0200
parents 140e2272471c
children d3aace9903fa
files th_datastruct.c th_datastruct.h
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/th_datastruct.c	Fri Jan 17 19:22:04 2020 +0200
+++ b/th_datastruct.c	Fri Jan 17 19:32:13 2020 +0200
@@ -333,7 +333,7 @@
     if ((res = th_malloc0(sizeof(th_ringbuf_t))) == NULL)
         return NULL;
 
-    if ((res->data = (char **) th_calloc(size, sizeof(char *))) == NULL)
+    if ((res->data = th_calloc(size, sizeof(void *))) == NULL)
     {
         th_free(res);
         return NULL;
@@ -349,10 +349,10 @@
 
 BOOL th_ringbuf_grow(th_ringbuf_t *buf, const size_t n)
 {
-    buf->data = (char **) th_realloc(buf->data, (buf->size + n) * sizeof(char *));
+    buf->data = (void **) th_realloc(buf->data, (buf->size + n) * sizeof(void *));
     if (buf->data != NULL)
     {
-        memset(buf->data + buf->size, 0, sizeof(char *) * n);
+        memset(buf->data + buf->size, 0, sizeof(void *) * n);
         buf->size += n;
         return TRUE;
     }
--- a/th_datastruct.h	Fri Jan 17 19:22:04 2020 +0200
+++ b/th_datastruct.h	Fri Jan 17 19:32:13 2020 +0200
@@ -53,9 +53,9 @@
  */
 typedef struct
 {
-    char **data;
     size_t n, size;
     void (*deallocator)(void *data);
+    void **data;    ///< Array of pointers to the data
 } th_ringbuf_t;