From c3902ebf55e8648d66ae99290d659c0802f66b7b Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Wed, 6 Nov 2013 10:52:45 +0200 Subject: Add _x_freep(): free allocated memory and set pointer to NULL --- include/xine/xineutils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 @@ -142,6 +142,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. */ -- cgit v1.2.3