Re: freeing memory

From: Peter Ajamian (peter@pajamian.dhs.org)
Date: 04/13/01


Mike Breuer wrote:
>
> ----- Original Message -----
> From: "Kras Kresh" <kras_kresh@HOTMAIL.COM>
> Sent: Friday, April 13, 2001 6:11 PM
>
> > Do you think I can just check if the string is the prototyped first?
> >
> > if (obj->description &&
> >     obj->description != obj_proto[GET_OBJ_RNUM(obj)].description)
> >   free(obj->description);
> > obj->description = str_dup("A dagger lies here.");
>
> That code should work fine, although the first condition of your if is not
> necessary.

Not necessary, but it's a good safegaurd nonetheless.

Regards, Peter

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST