Re: Problems with Linked Lists

From: Rasdan (rasdan@PEAK.ORG)
Date: 09/25/97


On Thu, 25 Sep 1997, Sammy wrote:

> >   while (fscanf(index, "%s %s", name, idnum) != EOF) {
> >     if (pie.name) {
> >       free (pie.name);
> >       pie.name = NULL;
> >     }
>
> It's also the broke part :)  First, you can't assume that pie.name 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 pie.name.  Since pie.name 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(pie.name) part out without
> worrying about a memory leak.
>

Thanks man, that solved my problem :)

Rasdan

=--=--=--=--=--=--=--=--=--=--=
  I have done so much,
  with so little,                         James C. Thomas Jr.
  for so long,                                  Rasdan
  That I can do anything                Head Coder of Finality!
  with nothing.
=--=--=--=--=--=--=--=--=--=--=
      Finality is based upon CircleMUD 3.0, check us out:
                 finality.mudservices.com 5555


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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