Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: initializing null pointers Message-ID: <7614@utzoo.UUCP> Date: Tue, 3-Feb-87 15:12:32 EST Article-I.D.: utzoo.7614 Posted: Tue Feb 3 15:12:32 1987 Date-Received: Tue, 3-Feb-87 15:12:32 EST References: <347@bms-at.UUCP> Organization: U of Toronto Zoology Lines: 15 > What about pointer arrays allocated with calloc()? Does one have to > initialize all the elements in a loop to be portable (despite the fact > that it is unnecessary on most machines)? Evidently, yes. ... 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. If it's equal, then calloc has done the right thing and you don't need the explicit loop. This won't cost much more than just trusting calloc, on machines where all-zeros does mean 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). -- Legalize Henry Spencer @ U of Toronto Zoology freedom! {allegra,ihnp4,decvax,pyramid}!utzoo!henry