[libdvdnav-devel] [RFC] Set free'd variables to NULL or not?

Andrew Clayton andrew at digital-domain.net
Fri Oct 24 17:45:07 CEST 2014


On Fri, 24 Oct 2014 16:26:56 +0200, Jean-Baptiste Kempf wrote:

> On 24 Oct, Andrew Clayton wrote :
> > I notice it is common practice in libdvdread to set free'd variables
> > to NULL. There are of course arguments for and against.
> 
> What is the use of setting them to NULL?
> Are they going to be reused and checked?

I personally don't set them to NULL in my projects. Some people do and
that seems to be the case in libdvdread. If anything it can probably
hide bugs, for example where you might be doing a double free.

If the consensus is to not set things to NULL after free then they can
simply be removed.

That would probably get my vote...

Cheers,
Andrew



More information about the libdvdnav-devel mailing list