[Courses] [C] Lesson12: Exercise answers

Luis M Ibarra mibarra at ximian.com
Thu Nov 21 19:04:51 EST 2002


On Thu, 2002-11-21 at 11:40, p k wrote:
> Is there any advantage for calloc over malloc or vice versa

Calloc is faster than malloc, but beware, they work quite different,
malloc allocates memory from the heap, calloc allocates from the stack. 

That means that calloc'ed memory is local to the function and won't be
available outside. It also means that you don't need to free calloc'ed
memory.


-- 
Luis M Ibarra <mibarra at ximian.com>
Ximian



More information about the Courses mailing list