Path: utzoo!attcan!uunet!lll-winken!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Is malloc() or calloc() "better"? Message-ID: <9353@smoke.BRL.MIL> Date: 12 Jan 89 19:35:34 GMT References: <9254@smoke.BRL.MIL> <17067@onfcanim.UUCP> <5003@aldebaran.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 17 In article <5003@aldebaran.UUCP> jimp@cognos.UUCP (Jim Patterson) writes: >I also agree that zero-filled memory isn't (maximally) portable, but I >still don't know what machines it's not portable to. Mark Brader has pointed out that the pANS imposes sufficient requirements on integers of all kinds that calloc() will properly initialize them too. Although ones-complement has -0, all-zero bits is +0, a valid zero value. The same is true of IEEE floating-point; there is a -0.0 but all-zero bits happens to be +0.0, a valid zero value. I think I've seen floating-point implementations where all-zero bits is not a valid representation of a zero value, but I don't recall where. (It is not required by the pANS.) The main culprit is null pointers, since there have been implementations where a null pointer was most conveniently represented by some pattern other than all-zero bits. None of this hides that fact that calloc() is a kludge.