From ff9d85872248f360aa76791b050872fb332a1ea0 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 15 Sep 2011 17:35:23 +0200 Subject: Make Curl_safefree() macro assign NULL to given pointer when free'd --- lib/memdebug.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 6e778b4da..1e02645f9 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -152,8 +152,10 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); /* * Curl_safefree defined as a macro to allow MemoryTracking feature * to log free() calls at same location where Curl_safefree is used. + * This macro also assigns NULL to given pointer when free'd. */ -#define Curl_safefree(ptr) do {if((ptr)) free((ptr));} WHILE_FALSE +#define Curl_safefree(ptr) \ + do {if((ptr)) {free((ptr)); (ptr) = NULL;}} WHILE_FALSE #endif /* HEADER_CURL_MEMDEBUG_H */ -- cgit v1.2.1