On the best way to NULL out a pointer after free: A macro or a function passed a pointer to a pointer

Simo simo at samba.org
Tue Jul 5 21:22:20 UTC 2016


On Tue, 2016-07-05 at 11:21 -0700, Richard Sharpe wrote:
> Hi folks,
> 
> Are there many open source projects out there that use the SAFE_FREE
> approach other than Samba.
> 
> I am currently embroiled in a discussion on which of these is a
> better
> approach. That is, a simple one-line macro like SAFE_FREE or a
> function that takes a pointer to a pointer?
> 
> The pointer to the pointer approach seems somehow obscene in this
> case.

You should use what is appropriate for the code (and coding style) at
hand. There is no TRUE/BEST method.

Simo.



More information about the samba-technical mailing list