calloc
Guy Harris
guy at auspex.auspex.com
Thu Apr 13 03:45:06 AEST 1989
>According to Harbison + Steele's book, calloc returns a region of
>memory with all bits set to zero. They also point out that pointers
>filled with zero bits do not necessarily have the value NULL, nor
>do arithmetic values consisting of zero bits have necessarily have the value
>zero. How can this be?
Easy. Consider a machine where the architects, or implementors of
languages available before C was made available, decided that a null
pointer was, say, a bit pattern with the value 0xff000000. Now, in
order to be compatible with those other languages, the implementors of C
made the bit pattern for a null pointer 0xff000000 as well.
>I always thought a pointer consisting of zero bits is NULL.
Nope. No such guarantee was ever made by any C language spec.
More information about the Comp.lang.c
mailing list