httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@algroup.co.uk>
Subject Re: Use of pcalloc()
Date Sat, 19 Jul 1997 11:14:07 GMT
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



Mime
View raw message