Path: utzoo!attcan!darkover!telly!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.lang.c Subject: Re: Is "if (!pointer)" as portable as "if (pointer == NULL)" ??? Keywords: portability, pointers, NULL Message-ID: <1990Apr14.133625.24487@druid.uucp> Date: 14 Apr 90 13:36:25 GMT References: <656@hades.OZ> <1461@tkou02.enet.dec.com> Reply-To: darcy@druid.UUCP (D'Arcy J.M. Cain) Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 19 In article <1461@tkou02.enet.dec.com> diamond@tkou02.enet.dec.com (diamond@tkovoa) writes: >In article <656@hades.OZ> greyham@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@druid) | Government: D'Arcy Cain Consulting | Organized crime with an attitude West Hill, Ontario, Canada | (416) 281-6094 |