free() and implicit conversion to a function pointer
Thu Mar 16 23:49:00 GMT 2017
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
> return void?
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)
>> would be
>> 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
More information about the Cygwin