Microport Unix -- Large Model Problems
tony mason
wmam at sphinx.UChicago.UUCP
Thu Nov 6 12:49:53 AEST 1986
In article <405 at maynard.UUCP> campbell at maynard.UUCP (Larry Campbell) writes:
>In article <347 at prairie.UUCP> dan at prairie.UUCP (Daniel M. Frank) writes:
>>In article <245 at rabbit1.UUCP> barber at rabbit1.UUCP (Steve Barber) writes:
>>>Another common problem is passing NULL as pointer argument. NULL is
>>>#defined as 0, which is 2 bytes. Large model pointers are 4 bytes, so
>>>the stack frame is now basically garbage.
>>
>> This isn't really true. Code in stdio.h for the SV/286 release
>>checks your memory model, and if it is large, defines NULL to be 0L,
>>which is the same size as a pointer. It doesn't please lint, so the
>>best solution is still to cast it as appropriate (like (char *)0),
>>but you ARE generally safe, as long as you include stdio.h.
>
>I wonder why stdio.h doesn't just declare NULL as "(char *) 0", or,
>in the brave new world of ANSI X-whatever, "(void *) 0"? This should
>do all the right things.
Note that in SCO XENIX (a/k/a MICROSOFT XENIX) they have declared NULL to be
of type (char *)0. Of course, you always have someone who will abuse this by
doing something stupid such as:
char buf[10];
buf[0] = NULL;
but they will learn!
The best practice is to cast it correctly (it sure makes lint happy!).
Tony Mason > No opinions expressed here. Only cold hard
University of Chicago > facts.
uucp: ...ihnp4!gargoyle!sphinx!wmam, ...ihnp4!gargoyle!euler!tony
bitnet: wmam%sphinx at UChicago.Bitnet
US. Lotto System (bet your 22 cents that it will get there!!!)
3854 S. Archer (312) 254-2114 home
Chicago, IL 60632
More information about the Comp.unix.wizards
mailing list