[comp.unix.xenix] NULL portability problmes

paul@cgh.UUCP (Paul Homchick) (07/26/87)

/* From <245@ddsw1.UUCP> comp.unix.xenix by karl@ddsw1.UUCP (Karl Denninger) */
>b)	(char *) variable, where variable contains 0, works in this
>	situation. (char *) NULL does not.
>c)	I am *not* passing NULL, but rather a POINTER to it. The value
>	pointed TO at that location should BE the null!

Regarding c), you are not passing a pointer to NULL, you are passing a
NULL pointer.  Stated in another way, (char *) NULL points to location
0 in the memory space.  Do you suppose that anything useful is stored
there?  Is location zero in protected memory?  God only knows the
answer to these questions.  This is not what you want to do.

Regarding b), it works because you are passing a pointer to what is
effectively a NULL-STRING.  What we want to make this work is a pointer
to a char containing 0x00.  Then any code that tests for a NULL will be
happy.  Passing a pointer to location 0 will usually not work because we
don't know what is there.  It may be a '\0', and then again, it may not. 

-- 
Paul Homchick            {seismo | allegra | ihnp4 | rutgers} !cbmvax!cgh!paul
Chimitt Gilman Homchick, Inc.; One Radnor Station, Suite 300; Radnor, PA 19087