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

"David Symonds" [off-list ref] wrote:
On Feb 17, 2008 1:58 PM, Jim Meyering [off-list ref] wrote:
quoted
This change removes all useless if-before-free tests.
E.g., it replace code like this

        if (some_expression)
                free (some_expression);

with the now-equivalent

        free (some_expression);

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
That's not great evidence. It only tests 9 systems, and misses several
If you mean mingw, cygwin, and M$-based ones, they're all ok.
As far as I know, you have to go back to SunOS4 to find a system on which
free(NULL) fails.  That OS stopped being a reasonable porting target
a couple years ago.
targets that Git already runs on. It seems like a fairly minor cleanup
for a definite loss of portability.
It's a definite loss of portability if you can find a reasonable porting
target for which free(NULL) fails.  But even if you do, the fix is
not to reject the clean-up, but to amend it with a wrapper function.
That encapsulates the work-around in one place rather than polluting
all of those files.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help