Ok, I've found some more stock ROM memory leaks… damn.
These are all in save.c.
In fread_char():
KEY( "Clan", ch->clan, clan_lookup(fread_string(fp)));
The problem with this is, fread_string() is going to str_dup() whatever
it reads in… and this never gets freed. To fix this, you have to
keep a pointer to the string you read in:
if ( !str_cmp( word, "Clan" ) )
{
char *tmp = fread_string(fp);
ch->clan = clan_lookup(tmp);
free_string(tmp);
fMatch = TRUE;
break;
}
In that same function, the same thing is done for race:
KEY( "Race", ch->race, race_lookup(fread_string(fp)));
This needs to be fixed in the same way.
And also, fread_pet() contains duplicates of these errors reading race
and clan values.
Can't believe I missed that one for all this time, bleah.
I think that would require additional checks for each index used to see if a pointer points to string space? It's possible to write a dynamic shared string manager using a hash table, it's not overly complicated.