summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Hintukainen <phintuka@users.sourceforge.net>2013-11-06 10:52:45 +0200
committerPetri Hintukainen <phintuka@users.sourceforge.net>2013-11-06 10:52:45 +0200
commitc3902ebf55e8648d66ae99290d659c0802f66b7b (patch)
tree96a0a88ebeaa98f7394173ca64d2aa80752ecb51
parent757cb2783a6155da53dd709aacd27cd5684fdddc (diff)
downloadxine-lib-c3902ebf55e8648d66ae99290d659c0802f66b7b.tar.gz
xine-lib-c3902ebf55e8648d66ae99290d659c0802f66b7b.tar.bz2
Add _x_freep(): free allocated memory and set pointer to NULL
-rw-r--r--include/xine/xineutils.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/xine/xineutils.h b/include/xine/xineutils.h
index 8e3394afd..3a997d2c2 100644
--- a/include/xine/xineutils.h
+++ b/include/xine/xineutils.h
@@ -143,6 +143,16 @@ void *xine_xmalloc(size_t size) XINE_MALLOC XINE_DEPRECATED XINE_PROTECTED;
void *xine_xcalloc(size_t nmemb, size_t size) XINE_MALLOC XINE_PROTECTED;
/*
+ * Free allocated memory and set pointer to NULL
+ * @param ptr Pointer to the pointer to the memory block which should be freed.
+ */
+static inline void _x_freep(void *ptr) XINE_PROTECTED {
+ void **p = (void **)ptr;
+ free (*p);
+ *p = NULL;
+}
+
+/*
* Copy blocks of memory.
*/
void *xine_memdup (const void *src, size_t length) XINE_MALLOC XINE_PROTECTED;