Coder's Guild Mailing List

RE: calloc vs. malloc

Posted by Eian Counts on 2000-07-15

Frank,

> The stupid thing seems to work today using either
> calloc or malloc. Go figure!!!

I am not totally sure, but for some reason I am
thinking that calloc specifically allocates a
sequential amount of memory where as malloc does not.
Meaning, that memory location 2 allocated with malloc
does not necessarily physically follow memory location
1. Make sense? 

This this in mind, if you were allocating a section of
memory and then were stepping through it (directly
with pointers), calloc would make sure that you could
do that. Where as if you used malloc there would be
the chance that it would work and that it wouldn't.

I am not able to get any documentation at this point
and so I can't confirm what I have just said, but I do
tend to think that I am correct (for once perhaps). :)

Eian



__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail – Free email you can access from anywhere!
http://mail.yahoo.com/