[Asterisk-Dev] any reason for #define FREE in the code ?

Luigi Rizzo rizzo at icir.org
Wed Dec 28 15:35:59 MST 2005


On Wed, Dec 28, 2005 at 03:08:40PM -0600, Kevin P. Fleming wrote:
> Luigi Rizzo wrote:
> > there are a few files, probably derived from some old template,
> > that still have these blocks:
> > 
> > 	#ifdef __AST_DEBUG_MALLOC
> > 	static void FREE(void *ptr)
> > 	{
> > 		free(ptr);
> > 	}
> > 	#else
> > 	#define FREE free
> > 	#endif
> 
> This is being done because there are API calls in those files that pass 
> the _address_ of free() to another function, and when AST_DEBUG_MALLOC 
> is enabled then free is a macro (with additional arguments), not a function.

ok but then i'd rather define the wrapper globally e.g. ast_free()
and let those function call the wrapper.
Even with the current solution you still don't get to see
the __FILE__ and __LINE__ of the "calling" function,
just those of the wrapper, which doesn't help too much.

cheers
luigi



More information about the asterisk-dev mailing list