Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!sdrc!scjones From: scjones@sdrc.UUCP (Larry Jones) Newsgroups: comp.lang.c Subject: Re: Is "if (!pointer)" as portable as "if (pointer == NULL)" ??? Keywords: portability, pointers, NULL Message-ID: <1283@sdrc.UUCP> Date: 11 Apr 90 21:59:51 GMT References: <656@hades.OZ> Organization: SDRC, Cincinnati Lines: 16 In article <656@hades.OZ>, greyham@hades.OZ (Greyham Stoney) writes: > Is this correct?. Can I just do: > if (buffer) free(buffer) > And stuff like that?. Yes. A null pointer is guaranteed to compare equal to zero, so if (ptr) and if (!ptr) are completely portable. Many will debate whether they are stylistically good or bad, but they definitely are portable. ---- Larry Jones UUCP: uunet!sdrc!scjones SDRC scjones@SDRC.UU.NET 2000 Eastman Dr. BIX: ltl Milford, OH 45150-2789 AT&T: (513) 576-2070 "You know how Einstein got bad grades as a kid? Well MINE are even WORSE!" -Calvin