Re: memorize from "Daniel Koepke" at Oct 2, 97 10:21:52 pm

From: Andrew Helm (ashe@IGLOU.COM)
Date: 10/02/97


>
> On Fri, 3 Oct 1997, Akuma/Chris Baggett/DOOMer wrote:
>
> -+ question here, doesn't Circle use the CREATE() macro?
> -+which in turn uses  _c_alloc()?  NOT _m_alloc()?
>
> Uhm, what's the point?  calloc() is just malloc() that takes
> an extra parameter.  They do (essentially) the same thing.

You know better than to say that. calloc() initializes the
allocted memory to zero while malloc() doesn't garantee anything
about it's contents. That and the fact that calloc() is much
slower than malloc() makes for a significant difference
between the two. They are not interchangeable. Code that uses
calloc() (eg- circle) often calloc()'s the memory for structures
instead of malloc()'ing it and seperately initialing each field
of the structure.


As a sidenote, since calloc() is so much slower than malloc()
it's handy to make another macro called MCREATE() that
malloc()'s memory instead. If you're allocating memory for
a string or something else that's going to be overwritten
anyways then use MCREATE().


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST