On Tue, 14 Dec 1999, Jason Beeland wrote:
> [snip]
         REMOVE_BIT(EXITN(ch->in_room, door)->exit_info, EX_FIRETRAP);
         for (kPrev = NULL, k = spec_door_list; k; kPrev = k, k = k->next)
           if (k->door == EXITN(ch->in_room, door))
             break;
         if (k) {
           if (kPrev) {
             kPrev->next = k->next;
           } else {
             spec_door_list = spec_door_list->next;
           }
           free(k);
         }
Note the movement of the free() statement inside of the "if (k) {}" block.
You do not want to try free(NULL).  Since we're expecting the door to be
in the spec_door_list at this point (at least, I think we are?) it'd make
sense to make a log() if we fail to find it in there, so:
    if (k) {
      if (kPrev) {
        kPrev->next = k->next;
      } else {
        spec_door_list = spec_door_list->next;
      }
      free(k);
    } else
      log("SYSERR: Expected firetrap to be in spec_door_list.");
> [snip]
Modify the rest of the code accordingly.
Lastly, what are we using the spec_door_list list for, anyway?  Obviously,
we're adding a firetrap door to the spec_door_list somewhere, and we're
removing it here ... are we ever traversing the list for some other
reason?  If the answer is no, you probably don't need a linked list to
begin with.
-dak : They're my initials.
     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST