[net.lang.c] sizes of pointers

ndiamond@watdaisy.UUCP (Norman Diamond) (02/07/85)

Two independent ideas here:

(1)  There still exists a wide variety of machines, including new ones
invented almost daily, where registers are not large enough to hold
pointers and address arithmetic is non-trivial and you would not want
to make sizeof (anytype *) == sizeof (int).  You still COULD increase
the size of an int so that sizeof (sometypes *) == sizeof (int), but
you would regret the waste of space and/or subroutine calls to do all
of your int arithmetic.

(2)  If you want to define some null pointer that's pretty well guaranteed
to work, and pass it as a parameter to a subroutine, you can make your
null pointer (char *) 0, and make all of your pointer parameters char *'s.
Why?  Because:  calloc returns a char *, and you can always cast the result
to convert to any kind of <type> * that you might need.  Therefore we know
sizeof (char *) >= sizeof (anytype *), for any anytype.  Of course, your
procedure calls will have to cast all pointer parameters to char *'s, and
your procedure code will have to cast them back.

-- 

   Norman Diamond

UUCP:  {decvax|utzoo|ihnp4|allegra|clyde}!watmath!watdaisy!ndiamond
CSNET: ndiamond%watdaisy@waterloo.csnet
ARPA:  ndiamond%watdaisy%waterloo.csnet@csnet-relay.arpa

"Opinions are those of the keyboard, and do not reflect on me or higher-ups."