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

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Jan 7 11:07:11 AEST 1989


In article <403 at laic.UUCP> darin at nova.UUCP (Darin Johnson) writes:
-Actually, calloc() is not always a shell around malloc()!  On an early
-Pyramid, I had spent lots of wasted time tracking down a bug, that fixed
-itself when I used free() for malloc()ed objects, and cfree() for
-calloc()ed objects.  In the buggy version, free() was used for
-everything...

The bug was in the Pyramid implementation of calloc()/cfree().
calloc()ed storage may legitimately be freed with free().



More information about the Comp.lang.c mailing list