]> jfr.im git - irc/blitzed-org/bopm.git/commitdiff
list_remove no longer checks for the existance of the node in the list
authorstrtok <redacted>
Thu, 19 Jun 2003 23:11:01 +0000 (23:11 +0000)
committerstrtok <redacted>
Thu, 19 Jun 2003 23:11:01 +0000 (23:11 +0000)
src/list.c

index e1def0aead2b75605c74d8e054ef87d917aa3ab9..09a643c60e5d9209f430a648ac5b0f34e93d4aea 100644 (file)
@@ -88,8 +88,6 @@ node_t *list_remove(list_t *list, node_t *node)
       else
          list->tail = NULL;
 
-      list->elements--;
-
       return node;
    }
    else if(node == list->tail)
@@ -97,24 +95,17 @@ node_t *list_remove(list_t *list, node_t *node)
       list->tail = list->tail->prev;
       list->tail->next = NULL;
 
-      list->elements--;
-
       return node;
    }
-
-
-   for(p = list->head; p != NULL; p = p->next)
+   else
    {
-      if(p == node)
-      {
-         p->prev->next = p->next;
-         p->next->prev = p->prev;
-         list->elements--;
-         return p;
-      }
+      node->prev->next = node->next;
+      node->next->prev = node->prev;
    }
 
-   return NULL;
+   list->elements--;
+   return node;
+
 }
 
 void list_free(list_t *list)