Re: free() problem

From: Patrick Dughi (dughi@imaxx.net)
Date: 01/31/01


> ok I really need help with this one, I've never bothered to free up memory
> befor (uniffant? yep) and now I'm having some problems with genobj.c's
> free_object_string_proto the lines are:
>
> -- MAILER CODE --
>   if (obj->short_description && obj->short_description !=
> obj_proto[robj_num].short_description)
>     free(obj->short_description);
>
> the free() line registers with gdb as the bug, now I've made a spell to
> alter the short_description of objects, I altered the short_description
> successfuly and then saved and quit, it crashed....

        Well, first, are you altering the template?  Are you freeing the
memory before you do so?  Are you allocating new memory for your new
string for just that individual object that you are changing?  Do you even
bother with memory - and thus are over/underwriting the allocated space
for the description?

        If you posted the spell you wrote, you'd probably get better help.

                                        PjD

--
   +---------------------------------------------------------------+
   | 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/03/01 PST