Thread (1 message) 1 message, 1 author, 2016-06-15

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

From: Jim Meyering <hidden>
Date: 2016-06-15 22:44:14

Johannes Schindelin [off-list ref] wrote:
On Sun, 17 Feb 2008, Jim Meyering wrote:
quoted
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
quoted
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.
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.
:-)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help