Re: Possible memory leak?

From: George Greer (greerga@circlemud.org)
Date: 12/02/01


On Sat, 1 Dec 2001, Daniel A. Koepke wrote:

>On Sat, 1 Dec 2001, George Greer wrote:
>
>> So create_entry() will not be called again:
>>
>>     if (GET_PFILEPOS(d->character) < 0)
>>       GET_PFILEPOS(d->character) = create_entry(GET_PC_NAME(d->character));
>
>...then why does create_entry() check for an existing entry in the player
>table?  There may be a reason for it, but I can't think of one which would
>make it okay to orphan the memory for the name in the player table.

It appears I had the same reaction you did to a potential memory leak
around patchlevel 15, except this case being a potential (but not real)
leak of an entire entry when re-added a deleted character.

>Then again, as you say, it may never be called in this case -- in which
>case, create_entry() should be simplified to remove the
>get_ptable_by_name() check.

Further investigation suggests that by saving/restoring the player file
position of a deleted character and re-using the slot, we have a mismatched
ID# in the character and the player_table[] until a reboot.  So the
get_ptable_by_name() is correct, it should just notice that it exists and
update the ID# instead of blindly recreating the name.

--
George Greer
greerga@circlemud.org

--
   +---------------------------------------------------------------+
   | 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 : 06/24/03 PDT