This topic is now archived and is closed to further replies.


Fun with calloc and malloc

Recommended Posts

Oh! That's right... I've used them before. I just completely forgot about them. Heh.

Oh, and one more thing: Does free() work with calloc()? Or do I have to use realloc() with a size of 0 to free memory allocated with calloc?

[edited by - Sirveaux on January 24, 2004 5:49:24 PM]

Share this post

Link to post
Share on other sites
free works with calloc.

You can find out more by using google like so: free

Which leads to free:



The free function deallocates a memory block (memblock) that was previously allocated by a call to calloc, malloc, or realloc. The number of freed bytes is equivalent to the number of bytes requested when the block was allocated (or reallocated, in the case of realloc). If memblock is NULL, the pointer is ignored and free immediately returns. Attempting to free an invalid pointer (a pointer to a memory block that was not allocated by calloc, malloc, or realloc) may affect subsequent allocation requests and cause errors.

Share this post

Link to post
Share on other sites