httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Jagielski <>
Subject Re: Use of pcalloc()
Date Sat, 19 Jul 1997 16:26:58 GMT
Rodent of Unusual Size wrote:
> >From the fingers of Alexei Kosut flowed the following:
> >
> >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?
>     Well, it's certainly no worse than using "if (!pointer)" to check
>     for a NULL value.
>     Of course, I would like to see that replaced with "if (pointer != NULL)"
>     throughout the code for clarity's sake - if not to protect against a
>     bad assumption of NULL's actual value.  The compiler will reduce it
>     to the same code, so there's no loss - only a gain of readability.

As far as ANSI is concerned, there is no difference between

	(!pointer) and (pointer != NULL)

      Jim Jagielski            |       jaguNET Access Services           |
            "Look at me! I'm wearing a cardboard belt!"

View raw message