git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

Previous: Morten Welinder
Message 18 of 18 in “Remove useless if-before-free tests.”
  1. Remove useless if-before-free tests.Jim Meyering, Feb 17, 2008
  2. David SymondsFeb 17, 2008
  3. Jim MeyeringFeb 18, 2008
  4. Junio C HamanoFeb 18, 2008
  5. Johannes SchindelinFeb 17, 2008
  6. Jim MeyeringFeb 18, 2008
  7. Jean-Luc HerrenFeb 18, 2008
  8. Jim MeyeringFeb 20, 2008
  9. Junio C HamanoFeb 22, 2008
  10. Jim MeyeringFeb 22, 2008
  11. Junio C HamanoFeb 22, 2008
  12. Jim MeyeringFeb 22, 2008
  13. Junio C HamanoFeb 22, 2008
  14. Jim MeyeringFeb 24, 2008
  15. Mike RalphsonFeb 26, 2009
  16. Uwe Kleine-KönigFeb 26, 2008
  17. Morten WelinderFeb 23, 2008
  18. Johannes SchindelinFeb 24, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.