RE: [code] Question on correctly freeing memory.

From: Gary Barnett (
Date: 09/13/96

On Thursday, September 12, 1996 4:47 PM, Skylar[] wrote:
>On Thu, 12 Sep 1996, Gary Barnett wrote:
>> I am working on having customized object descriptions save with the objects in
>> the rent system. I have the code working correcty, but am not sure of the correct
>> way to free the memory in use before assigning the new description. Here is
>> the relevant code.. Any thoughts on how to plug the resulting memory leak will
>> be most appreciated:
>What makes you think theres a memory leak?  As far as I can see, in pl11, the
>free_obj() function in db.c (which is called from extract_obj() in handler.c)
>checks if the descriptions are pointers to the prototype obj's description,
>and if they're not it free's them... as it should be, else you'll be freeing
>up the descriptions of all objs of that num... this should peacefully work
>with what you've done and handle all the free'ing on its own...

Agreed. I guess I was looking for problems where there were none. One question though:
in do_string .. is this the correct method of assigning the 'new' description to an object
currently loaded in the game? Specifically is str_dup the correct choice? 

case 's':
case 'S':
   obj->short_description = str_dup(arg3);
   send_to_char("Updated the short description.\r\n",ch);

Where arg3 is defined as: char arg3[MAX_INPUT_LENGTH]; and is assigned it's
value from half_chop.

Thanks in advance,


- - (4000)

| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   |

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