Infinite loops

From: George (greerga@DRAGON.HAM.MUOHIO.EDU)
Date: 08/21/97


I recommend this construct for every for() loop in CircleMUD:

    for (toy = get_buffer_head(); toy; toy = toy->next)
      if (toy == toy->next) {
        log("SYSERR: BUF: do_buffer: Infinite loop!");
        toy->next = NULL;
      } else if (!toy->used && toy->size == size &&

I once had an infinite loop in my character_list somehow because the next
pointer pointed back to the character with the next pointer.  Won't solve a
problem with the last person being linked to the first person, but it will
at least provide some safety from simple problems.  This can of course be
fooled by a next pointer that points to the previous entry but a) I'd have
to allocate a pointer to hold the previous entry and b) you would almost
have to be trying to do it.

This might be the right track (not necessarily fix) for the char_to_room()
twice problem.

--
greerga@muohio.edu me@null.net | Genius may have its limitations, but stupidity
http://www.muohio.edu/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | 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