Re: Problems with Linked Lists

From: Sammy (samedi@DHC.NET)
Date: 09/25/97

On Thu, 25 Sep 1997, Rasdan wrote:

> void load_player_index(void)
> {
>   struct player_index_element pie;
>   /* Open file stuff here -- This part is easy */
>   while (fscanf(index, "%s %s", name, idnum) != EOF) {
>     if ( {
>       free (;
> = NULL;
>     }

It's also the broke part :)  First, you can't assume that will
be initialized to NULL on the first pass.  It's ok now, but you may have
problems with another compiler when you try to free a nonexistant pointer.

As for your name problem, look at what you're doing here.  On each pass
after the first, you're freeing  Since is the name of
the last player you loaded from the index, you're destroying what you've
just done.  You can safely take that whole if( part out without
worrying about a memory leak.


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

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