Re: [PATCH] Remove useless if-before-free tests.
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Feb 24, 2008, 10:06 UTC
- Message-ID
- <alpine.DEB.1.00.0802241100350.6881@eeepc-johanness>
- In-Reply-To
- <118833cc0802230530l104acc72k20ceb4b5adcff937@mail.gmail.com>
Hi,
On Sat, 23 Feb 2008, Morten Welinder wrote:
Show 14 quoted lines
> > +inline void gitfree(void *ptr)
> > +{
> > + if (ptr)
> > + free(ptr);
> > +}
> > +#define free gitfree
> > +#endif
>
> I am wondering why you do it this way. "#define free gitfree" is just
> not valid in a C program that includes the relevant standard header.
> "free" is a reserved symbol.
>
> To stay within the standard, do the define the other way and use
> gitfree everywhere.We do it this way for other things like fopen, too.
Besides, I think that there should be at least one _real_ case where it actually _breaks_ before we have a big, ugly, change where it is easy to overlook a non-converted "free()", instead of a nice, clean and short patch.
Ciao, Dscho