Path: utzoo!utgpu!watmath!onfcanim!dave From: dave@onfcanim.UUCP (Dave Martindale) Newsgroups: comp.lang.c Subject: Re: Is malloc() or calloc() "better"? Message-ID: <17067@onfcanim.UUCP> Date: 4 Jan 89 23:49:14 GMT References: <9254@smoke.BRL.MIL> Reply-To: dave@onfcanim.UUCP (Dave Martindale) Organization: National Film Board / Office national du film, Montreal Lines: 11 I haven't used calloc for years. I malloc a chunk of memory, then explicitly initialize the things that need to be initialized. This allows the reader to see exactly what the default values are, and which fields need to be provided with values. It also avoids a nasty portability bug: I've seen people who use calloc to zero their allocated arrays or structures assume that "all bits zero" is the proper value for floating-point zero - definitely not true on all machines. An explicit initialization to 0.0 is always correct.