Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!sri-spam!mordor!lll-lcc!styx!twg-ap!amdahl!pyramid!decwrl!decvax!tektronix!orca!tekecs!stalker!jans From: jans@stalker.UUCP Newsgroups: comp.lang.c Subject: Re: initializing null pointers Message-ID: <8134@tekecs.TEK.COM> Date: Fri, 6-Feb-87 11:04:11 EST Article-I.D.: tekecs.8134 Posted: Fri Feb 6 11:04:11 1987 Date-Received: Sun, 8-Feb-87 06:00:38 EST References: <347@bms-at.UUCP> <7614@utzoo.UUCP> Sender: nobody@tekecs.TEK.COM Reply-To: jans@stalker.UUCP (Jan Steinman) Organization: Tektronix, Inc., Wilsonville, OR Lines: 20 In article <7614@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes: >> What about pointer arrays allocated with calloc()? Does one have to >> initialize all the elements in a loop to be portable... > >Fraid so. What you might do, though, if you are willing to risk some small >degree of unportability for the sake of efficiency, is first test an element >of the array for equality to NULL... > >The small portability risk in this is the possibility that an all-zeros >pointer might have magic properties (e.g. trap on any use of it). Or that you might, by chance, have tested a pointer that had been NULL in a previous life! The most portable thing to do is NEVER dereference a pointer that has not been initialized. Some micro compilers I've used don't even initialize automatics! :::::: Artificial Intelligence Machines --- Smalltalk Project :::::: :::::: Jan Steinman Box 1000, MS 60-405 (w)503/685-2956 :::::: :::::: tektronix!tekecs!jans Wilsonville, OR 97070 (h)503/657-7703 ::::::