Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ucla-cs!zen!ucbvax!decvax!ima!mirror!xanth!john From: john@xanth.UUCP (John Owens) Newsgroups: comp.unix.xenix Subject: Re: Microport Users' Group Bug List (LONG) Message-ID: <1702@xanth.UUCP> Date: Sun, 26-Jul-87 17:42:31 EDT Article-I.D.: xanth.1702 Posted: Sun Jul 26 17:42:31 1987 Date-Received: Tue, 28-Jul-87 02:12:42 EDT References: <166@qetzal.UUCP> <157@hobbes.UUCP> <245@ddsw1.UUCP> Organization: Old Dominion University, Norfolk Va. Lines: 45 In article <245@ddsw1.UUCP>, karl@ddsw1.UUCP (Karl Denninger) writes: > a) NULL is declared in large model programs to be '0L' (look in the > header file) This is incorrect, and a kludge to "help" those programs that pass NULL to functions without casting it first. NULL should be "0" for all models, and should always be cast to the appropriate type to get its length right. (I.E., passing "(char *) 0" in small model will push 16 bits of zeros; passing the same thing in large model will push 32 bits.) > b) (char *) variable, where variable contains 0, works in this > situation. Sure, since you are passing an address which points to something; in this case, it points to a zero character. See below: > . . . (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! No, you *are* passing NULL, which is 0. There *is* no value that this points to - that's why it's NULL. Why do you think you're passing a pointer to NULL? The cast? No, that just changes the type. It is always illegal to dereference NULL. The confusion comes about because many implementations, again to "help" incorrect programs, make sure to put a zero word (or more) at location zero, so that incorrectly dereferencing NULL will still get you a null string, or whatever (depending on type). In small model, Xenix does this, so you can dereference DS:0000 with no error. In large model, it can't let you dereference 0000:0000, so you get a segmentation fault. > Will be more than happy to eat my bug report if there's a good reason why > the cast which I included does not produce the desired result -- especially > if someone can explain why example (b) works! I hope I've explained it clearly - if not, let me know. Again, the cast, in this case, just makes sure the argument passed on the stack is the right size. -- John Owens Old Dominion University - Norfolk, Virginia, USA john@ODU.EDU old arpa: john%odu.edu@RELAY.CS.NET +1 804 440 4529 old uucp: {decuac,harvard,hoptoad,mcnc}!xanth!john