This is the mail archive of the
mailing list for the Cygwin project.
Re: free() and implicit conversion to a function pointer
- From: Hans-Bernhard Bröker <HBBroeker at t-online dot de>
- To: cygwin at cygwin dot com
- Date: Fri, 17 Mar 2017 00:49:15 +0100
- Subject: Re: free() and implicit conversion to a function pointer
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com> <firstname.lastname@example.org> <58CB07A8.email@example.com>
Am 16.03.2017 um 22:46 schrieb L A Walsh:
Going by subj and talk below, this is a bit confusing...
But it looks like you are testing 'free' for a value?
Not really. The idea is to test free for _exixtence_. Which only makes
sense in case of weak symbol support getting involved. In other
situations, there could not possibly be a need for a run-time if() test,
because surely the code could know at build time whether free() exists
Isn't standard 'free' declared to take 1 arg and
Yes. But since the code in question doesn't actually _call_ free,
that's both irrelevant.
If you aren't talking standard 'free()', then
We are talking standard free. More to the point, we're discussing
newlib, the package that actually implements free() for cygwin.
The only code that might actually be a slight bit better than the given
if (! free)
if (0 != free)
The function designator `free' auto-decays into a function pointer,
which is compared to a null pointer constant: 0. The ! operator does
that same thing implicitly, but is fully equivalent to it.
Free autodecays to a function pointer?
In the use case at hand: yes, it does.
In what language?
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple