[Circle] [CODE] running thru a list.

From: Rasmus 'Con' Ronlev (raro94ab@hp4.econ.cbs.dk)
Date: 08/23/96


Hi,

I was totaly convinced till now, that I understood the concept of running
through a linked list, but the following routine causes me a lot of grief:

struct rumble_list_type
{
  long id;
  struct rumble_list_type *next;
};

void rumble_char_check_remove(struct char_data * ch)
{
  struct rumble_list_type *l, *tmp;

  for (l = rumble_list; l; l = l->next)
  {
    if (GET_IDNUM(ch) == l->id)
    {
      tmp = l;
      l = l->next;
      free(tmp);
      return;
    }
  }
}

Allso got another snipped.. *G*

In another routine activated by the player, if he wants to join a rumble,
the following code is run (after a lot of checks, etc).

  CREATE(tmp, struct rumble_list_type, 1);
  tmp->id = 0;
  tmp->next = NULL;

  tmp->id = GET_IDNUM(ch);

  tmp->next = rumble_list;
  rumble_list = tmp;
  rcontroll.joined++;

Well, thats it.. Creaing the list the first time is no problem, but as
soon as everyone has left the rumble, and they 'restart' entering it, i.e.
add themsevles to the 'should be NULL rumble_list' the mud segfaults.
I've tried to resolve the problem with gdb, but I cant get any usable
output from ie, i.e. a line where it crashes.

Anyone got any ideas how to make diz' work ?

Regards,
Con.

d.
--
     Rasmus Rønlev DOEK'94      WWW: http://www.econ.cbs.dk/people/raro94ab
     Student instructor         MUD: exiled.mud.circlemud.org 5000
                                         199.199.16.100 5000
       Student, B.Sc in Computer Science and Business Administration.

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



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