I noticed something curious while looking at a bit of Mutt code...
The macro FREE() is redundant: it's defined to safe_free(), which
has exactly the same interface, and which itself has two
implementations.  One is in lib.c, the other in rfc822.c.  They are
different, but similar.  The lib.c implementation is this:

void safe_free (void *ptr)      /* __SAFE_FREE_CHECKED__ */
{
  void **p = (void **)ptr;
  if (*p)
  {
    free (*p);                          /* __MEM_CHECKED__ */
    *p = 0;
  }
}


Is there any specific reason the implementation was written thusly?
Granted, this is a pretty minor issue...  But still, this all seems
kind of gross.  First, there really ought to be one implementation.
Second, the above implementation has some redundancies:

 - It requires a function call
 - Calling free(NULL) is a noop--perfectly safe (at least since ANSI
   C, I don't have a copy of K&R handy)
 - the extra cast seems silly; ptr is required to be **ptr, it should
   be declared that way.

I'm not much of a fan of function-like macros in general, but this
case seems like exactly when you'd want to use one.  I think this
should be replaced with:

#define FREE(x)\
        free((x));\
        x = NULL

Then safe_free() should be eliminated.

Again, this is a minor issue, but I see no reason not to address it.
I'll work on the patch (I don't have/use/know git, so it would be
based on 1.5.21) IFF anyone cares, and I'm not wrong.

-- 
Derek D. Martin    http://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.

Attachment: pgp3fQ4RdwJws.pgp
Description: PGP signature

Reply via email to