Path: utzoo!attcan!uunet!mitel!sce!cognos!jimp From: jimp@cognos.uucp (Jim Patterson) Newsgroups: comp.lang.c Subject: Re: Is malloc() or calloc() "better"? Message-ID: <4999@aldebaran.UUCP> Date: 10 Jan 89 14:11:01 GMT References: <9254@smoke.BRL.MIL> <46857@yale-celray.yale.UUCP> <9339@ihlpb.ATT.COM> Reply-To: jimp@cognos.UUCP (Jim Patterson) Organization: Cognos Inc., Ottawa, Canada Lines: 20 In article <9339@ihlpb.ATT.COM> nevin1@ihlpb.UUCP (55528-Liber,N.J.) writes: >In article <46857@yale-celray.yale.UUCP> wald-david@CS.YALE.EDU (david wald) writes: > >| In some virtual memory systems it is >|possible to allocate memory filled with a zero bit pattern without >|actually paging through the memory range. > >In this case, wouldn't malloc() just call the same routine as calloc()? It may, initially, but it also will recycle memory returned by a free() call. malloc() is under no obligation to clear its memory and it's extremely foolhardy to assume that it will. calloc() must clear the area it returns, or it's broken. -- Jim Patterson Cognos Incorporated UUCP:decvax!utzoo!dciem!nrcaer!cognos!jimp P.O. BOX 9707 PHONE:(613)738-1440 3755 Riverside Drive Ottawa, Ont K1G 3Z4