Re: Erasing certain info from a link list.

From: George Greer (greerga@circlemud.org)
Date: 10/24/02


On Thu, 24 Oct 2002, David Cole wrote:

>   for (smd = ch->MemList; smd; smd = smd->next) { // Here
>     if (smd->spell == spell) // Here
>          DeleteMemorieSpell(ch, smd); // Here
>   }
> }

Maybe you want REMOVE_FROM_LIST() ??  After you've removed it from the
list, you still have a pointer to it so you can do whatever unspeakable
things to it you want.

> sprintf(BufOne, "You purge '%s' from your thoughts.\r\n",
>spell_info[spell].name);
> send_to_char(BufOne, ch);

Get the latest bpl versions for:

  send_to_char(ch, "You purge '%s' from your thoughts.\r\n",
        spell_info[spell].name);

>    for (temp = ch->MemList; temp && (temp->next != smd); temp =
>temp->next);
>    if (temp)
>      temp->next = smd->next;
>  }

It's very naughty to remove an item from a list someone else is traversing
without a temporary marker. (See 'next_char' uses.)

>  FREE((char *) smd);
>  smd = NULL;
>}

No reason to NULL it.

--
George Greer
greerga@circlemud.org

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT