FREE

Mark Brader msb at sq.sq.com
Sat Mar 3 15:34:54 AEST 1990


> Why is NOT malloc() made to initialize the contents automatically?
> Is the efficiency a matter here?

Yes, it is.  For many applications there is no point in initializing it
because the next thing you're going to do is overwrite the entire space
anyway.  In addition, malloc() does not know what type of data you're
going to put in the allocated space, and so it couldn't tell what initial
value to put there anyway.  (calloc() puts all zero bits, which is only
useful for integer types.)

-- 
Mark Brader, SoftQuad Inc., Toronto		"Remember the Golgafrinchans"
utzoo!sq!msb, msb at sq.com					-- Pete Granger

This article is in the public domain.



More information about the Comp.lang.c mailing list