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

Re: [PATCH] Remove useless if-before-free tests.

From
Jim Meyering <jim@meyering.net>
Date
Feb 18, 2008, 09:01 UTC
Message-ID
<87ve4my6y2.fsf@rho.meyering.net>
In-Reply-To
<alpine.LSU.1.00.0802172210470.30505@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 11 quoted lines
> On Sun, 17 Feb 2008, Jim Meyering wrote:
>
>> It is equivalent not just because POSIX has required free(NULL) to work
>> for a long time, but simply because it has worked for so long that no
>> reasonable porting target fails the test. Here's some evidence from
>> nearly 1.5 years ago:
>>
>>     http://www.winehq.org/pipermail/wine-patches/2006-October/031544.html
>
>>From this mail, we see that there is at least one target where this leads
> to a crash (remember, git should run on more platforms than Wine).
Hi,
Thanks for the feedback.

FYI, you don't have to go back 20+ years to 3BSD to find a system on which free(NULL) fails :-) SunOS4's did, too. So if that is a reasonable porting target for git, then you will need the wrapper. With references to "SunOS" in Makefile and configure, I did wonder about that. Let me know and I'll adjust the proposed patch.

Show 14 quoted lines
> However, such a crash is pretty obvious in our test-suite, I guess, and
> thus we could easily introduce something like this into git-compat-util.h
> should the need ever arise:
>
> #ifdef FREE_NULL_CRASHES
> inline void gitfree(void *ptr)
> {
> 	if (ptr)
> 		free(ptr);
> }
> #define free gitfree
> #endif
>
> IOW I like that type of cleanup.
:-)
Previous: Johannes SchindelinNext: Jean-Luc Herren
Message 6 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.