FREE

Michael Meissner meissner at osf.org
Sat Mar 3 04:44:43 AEST 1990


In article <1990Mar2.152601.8000 at cubmol.bio.columbia.edu>
ping at cubmol.bio.columbia.edu (Shiping Zhang) writes:

| My question is
|     Why is NOT calloc() made machine independent.
| I also often asked (to myself)
|     Why is NOT malloc() made to initialize the contents automatically?
| I simply can not think of any case where the initial contents would
| be useful for some purpose and should be preserved. Is the efficiency
| a matter here?

If you are allocating a very large area, and then set the area to all
0's (or whatever bit pattern you want) on a virtual memory system, it
will force each of the pages to be faulted in, which can be bad.  For
example, if you allocate a 10 meg chunk for the worst case senario,
and only use say 256K, clearing the memory would force would touch
9.75 meg of pages uselessly.  A friend of mine sped up a linker on
exactly this problem.
--
Michael Meissner	email: meissner at osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA

Catproof is an oxymoron, Childproof is nearly so



More information about the Comp.lang.c mailing list