Is malloc() or calloc() "better"?

Jim Patterson jimp at cognos.uucp
Wed Jan 11 00:11:01 AEST 1989


In article <9339 at ihlpb.ATT.COM> nevin1 at ihlpb.UUCP (55528-Liber,N.J.) writes:
>In article <46857 at yale-celray.yale.UUCP> wald-david at 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



More information about the Comp.lang.c mailing list