changeset 192:7d25d43a3ce2

Add new function th_free_r(void **ptr) that calls th_free(*ptr) and sets *ptr to NULL.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 11 Feb 2016 16:10:31 +0200
parents cc5411cb85de
children 2b64ad9cdc5f
files th_util.c th_util.h
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/th_util.c	Thu Feb 11 16:09:12 2016 +0200
+++ b/th_util.c	Thu Feb 11 16:10:31 2016 +0200
@@ -233,6 +233,16 @@
 }
 
 
+void th_free_r(void **p)
+{
+    if (p != NULL)
+    {
+        th_free(*p);
+        *p = NULL;
+    }
+}
+
+
 /* Doubly linked list handling
  *
  * In this implementation first node's prev points to last node of the list,
--- a/th_util.h	Thu Feb 11 16:09:12 2016 +0200
+++ b/th_util.h	Thu Feb 11 16:10:31 2016 +0200
@@ -149,6 +149,7 @@
 void    *th_calloc(size_t, size_t);
 void    *th_realloc(void *, size_t);
 void    th_free(void *);
+void    th_free_r(void **);
 
 
 /* Doubly linked list handling