From 9194e1700312f27c6e2abdfb1f604e130497e887 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 2 Sep 2011 19:40:53 +0200 Subject: MemoryTracking: fix logging of free() calls done where Curl_safefree is called Just internal stuff... Curl_safefree is now a macro defined in memdebug.h instead of a function prototyped in url.h and implemented in url.c, so inclusion of url.h is no longer required in order to simply use Curl_safefree. Provide definition of macro WHILE_FALSE in setup_once.h in order to allow other macros such as DEBUGF and DEBUGASSERT, and code using it, to compile without 'conditional expression is constant' warnings. The WHILE_FALSE stuff fixes 150+ MSVC compiler warnings. --- lib/memdebug.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 02df08877..a042bb474 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,6 +1,6 @@ -#ifdef CURLDEBUG #ifndef HEADER_CURL_MEMDEBUG_H #define HEADER_CURL_MEMDEBUG_H +#ifdef CURLDEBUG /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -139,9 +139,21 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #endif /* MEMDEBUG_NODEFINES */ -#endif /* HEADER_CURL_MEMDEBUG_H */ #endif /* CURLDEBUG */ +/* +** Following section applies even when CURLDEBUG is not defined. +*/ + #ifndef fake_sclose -#define fake_sclose(x) +#define fake_sclose(x) do { } WHILE_FALSE #endif + +/* + * Curl_safefree defined as a macro to allow MemoryTracking feature + * to log free() calls at same location where Curl_safefree is used. + */ + +#define Curl_safefree(ptr) do {if((ptr)) free((ptr));} WHILE_FALSE + +#endif /* HEADER_CURL_MEMDEBUG_H */ -- cgit v1.2.3