Re: Memory issues.

Davion Kalhen <[email protected]>
Newsgroups gmane.games.devel.mud.rom
Message-ID <[email protected]>
> 
>             if ( !str_cmp( word, "Skill" ) || !str_cmp(word,"Sk") )
>             {
>                 int sn;
>                 int value = fread_number( fp );
>                 char *temp = fread_word( fp );
> 
>                 sn = skill_lookup(temp);
> 
>                 if ( sn < 0 )
>                 {
>                     sprintf(buf, "Fread_char: unknown skill - %s",temp);
>                     bug( buf, 0 );
>                 }
>                 else
>                     ch->pcdata->learned[sn] = value;
> 
>                 free_string(temp);
>                 fMatch = TRUE;
>             }
> 
>

Your using fread_word there. fread_word does -NOT- allocate memory. So
you have nothing to free. The problem with that is the string is saved
for use with fread_string so everything read will have a tilde at the
end. The reason for this is some spells are multipul words, and as the
name of the function implys fread_word only reads till whitespace or
eof/eol, sooo, you might want to consider using fread_string there.
-- 
ROM mailing list
[email protected]
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.