There are 300-odd calls to xfree in tmux and it looks like only about 50
have a check. Those are the ones where we explicitly know that NULL is a
possibility. I don't think it adds much work to do this, I just don't
know if it actually helps to catch bugs or document anything.


On Sun, Jun 03, 2012 at 08:05:33PM +0100, Thomas Adam wrote:
> Hi,
> 
> On 3 June 2012 19:44, Nicholas Marriott <nicholas.marri...@gmail.com> wrote:
> > It isn't there to be defensive, free(NULL) of course is always
> > guaranteed to be safe. It's a deliberate aid to writing correct code,
> > you should know where your null pointers are. Whether it actually helps
> > or not is another matter :-).
> 
> Hehe.  I really don't think it does help -- all it does is pepper the
> code with "if (foo != NULL) xfree (foo);" for the uncommon case, where
> you're guarding against nothing for no good reason, in my opinion.
> Yes, knowing where your NULLs are is definitely a good thing to know,
> but in the case where you might have malloc()d something or not
> (because a certain element hasn't changed, or had a value set), and
> you then have to code around that eventuality just to free it, which
> is safe w.r.t NULL, creates unnecessary work, IMO.
> 
> Kindly,
> 
> -- Thomas Adam

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to