Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!decwrl!ucbvax!agate!apple!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: use of if (!cptr) and if (cptr), where cptr is a * Message-ID: <10549@smoke.BRL.MIL> Date: 19 Jul 89 05:56:31 GMT References: <10099@mpx2.mpx.com> <93@microsoft.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 14 In article <93@microsoft.UUCP> paulc@microsoft.UUCP (Paul Canniff 2/1011) writes: >It will break if NULL != 0. malloc() is required to return a null pointer when it cannot allocate the storage. Having stashed that into a variable named "sptr", the test (!sptr) is required to correctly determine whether or not sptr is a null pointer, so the whole procedure is correct. What NULL may be defined as in some header is irrelevant here. Anyway, in standard headers that define NULL, NULL must be defined to be a valid generic null pointer (0 or (void*)0 for Standard C). There are some known bogus C implementations that define NULL as 0L or other warped flavors of 0, but I've never heard of one so far gone as to define NULL to be something totally unusable as a null pointer constant.