Received: (from majordom@localhost) by hyperreal.org (8.8.5/8.8.5) id EAA07702; Sat, 19 Jul 1997 04:14:55 -0700 (PDT) Received: from eastwood.aldigital.algroup.co.uk (eastwood.aldigital.algroup.co.uk [194.128.162.193]) by hyperreal.org (8.8.5/8.8.5) with SMTP id EAA07694 for ; Sat, 19 Jul 1997 04:14:50 -0700 (PDT) Received: from freeby.ben.algroup.co.uk (freeby.ben.algroup.co.uk [193.133.15.6]) by eastwood.aldigital.algroup.co.uk (8.6.12/8.6.12) with ESMTP id LAA20523 for ; Sat, 19 Jul 1997 11:14:34 GMT Received: from naughty (naughty.ben.algroup.co.uk [193.133.15.107]) by freeby.ben.algroup.co.uk (8.6.12/8.6.12) with ESMTP id MAA11751 for ; Sat, 19 Jul 1997 12:14:16 +0100 Message-ID: <33D0A17E.CB391D60@algroup.co.uk> Date: Sat, 19 Jul 1997 12:14:07 +0100 From: Ben Laurie Organization: A.L. Digital Ltd. X-Mailer: Mozilla 4.01 [en] (WinNT; I) MIME-Version: 1.0 To: new-httpd@apache.org Subject: Re: Use of pcalloc() X-Priority: 3 (Normal) References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org Alexei Kosut wrote: > Hmm. > > I recently noticed something: The Apache code uses pcalloc() a lot to > allocate memory and initialize it, since pcalloc() (like its > similar-named calloc()) fills with zeros what it initializes. However, > > isn't it illegal to assume that this will correctly make a structure's > > members which are pointers null, since the null pointer is not > neccessarily represented by an all-bits zero pointer internally? > > Now certainly we've never had any bug reports on this, so I imagine it > > works on nearly every OS out there. But isn't it still a bad practice? Although you are, strictly, correct, the equivalence between all zeroes and NULL is so widely assumed, and the difficulty of implementing a non-zero NULL so large, that I really don't believe it will ever prove to be a problem (though there is the interesting case of 16-bit segmented architectures - but they are so appallingly broken anyway they are hardly worth considering). There is a comment to the effect that we make this assumption in a header somewhere. Cheers, Ben. -- Ben Laurie Phone: +44 (181) 994 6435 Email: ben@algroup.co.uk Freelance Consultant and Fax: +44 (181) 994 6472 Technical Director URL: http://www.algroup.co.uk/Apache-SSL A.L. Digital Ltd, Apache Group member (http://www.apache.org) London, England. Apache-SSL author