From: Eric Bollengier Date: Sat, 25 Jul 2009 21:30:08 +0000 (+0000) Subject: change free_and_null function to a macro X-Git-Tag: Release-5.0.0~461 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c72477e19b10d90208330d25cb81f159a49d8fc3;p=bacula%2Fbacula change free_and_null function to a macro git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@9101 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 2d149c02f8..24301083f3 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -612,8 +612,8 @@ int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...) #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size)) #endif -/* Function to simplify free/reset pointers */ -inline void bfree_and_null(void *&a) { if (a) { free(a); a = NULL; } } +/* Macro to simplify free/reset pointers */ +#define bfree_and_null(a) do{if(a){free(a); (a)=NULL;}} while(0) /* * Replace codes needed in both file routines and non-file routines diff --git a/bacula/src/lib/mem_pool.h b/bacula/src/lib/mem_pool.h index b4d2512ba3..3624de8d72 100644 --- a/bacula/src/lib/mem_pool.h +++ b/bacula/src/lib/mem_pool.h @@ -70,15 +70,8 @@ extern void free_pool_memory(POOLMEM *buf); #endif -/* Function to simplify free/reset pointers */ -inline void bfree_and_null(POOLMEM *&a) { - if (a) { - free_pool_memory(a); - a = NULL; - } -} - -#define free_and_null_pool_memory(a) bfree_and_null((a)) +/* Macro to simplify free/reset pointers */ +#define bfree_and_null_pool_memory(a) do{if(a){free_pool_memory(a); (a)=NULL;}} while(0) extern void garbage_collect_memory_pool(); extern void close_memory_pool();