From e2d393bd24e5b8ae3588828113993399bb105b32 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 17 Sep 2001 00:47:40 +0000 Subject: introduce SAFE_FREE() macro as suggested by andreas moroder. (This used to be commit b7edd55885791f9aded11a0b0a131e02a819f374) --- source3/include/smb_macros.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/include/smb_macros.h') diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 52649ffc39..bf6e3c9fb9 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -37,6 +37,9 @@ #define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0) #define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0) +/* free memory if the pointer is valid and zero the pointer */ +#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) + /* zero a structure */ #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) -- cgit