Is "if (!pointer)" as portable as "if (pointer == NULL)" ???
D'Arcy J.M. Cain
darcy at druid.uucp
Sat Apr 14 23:36:25 AEST 1990
In article <1461 at tkou02.enet.dec.com> diamond at tkou02.enet.dec.com (diamond at tkovoa) writes:
>In article <656 at hades.OZ> greyham at hades.OZ (Greyham Stoney) writes:
> [...]
>> if (buffer) free(buffer)
>
>This is also portable, and almost readable. Again, to be really readable,
>you should still compare to NULL, but I grant that it would make your
>source code longer this time.
>
I know that NULL == 0 but I can't help feeling nervous about it. I always
use something like "if (buffer == NULL)" and assume that the optimiser will
do the right thing. Am I too paranoid or is this good defensive programming?
--
D'Arcy J.M. Cain (darcy at druid) | Government:
D'Arcy Cain Consulting | Organized crime with an attitude
West Hill, Ontario, Canada |
(416) 281-6094 |
More information about the Comp.lang.c
mailing list