ptrlist.c

changeset 111
7d1dccdd7215
parent 101
50525dab6c8e
--- a/ptrlist.c	Tue Apr 24 19:00:47 2007 +0200
+++ b/ptrlist.c	Sun May 06 16:05:59 2007 +0200
@@ -53,6 +53,12 @@
 }
 
 
+bool ptrlist_contains(PtrList *ptrlist, void *ptr)
+{
+    return (ptrlist_find_node(ptrlist, ptr)!=NULL);
+}
+
+
 bool ptrlist_insert_last(PtrList **ptrlist, void *ptr)
 {
     PtrList *node=mknode(ptr);
@@ -84,7 +90,7 @@
     PtrList *node=ptrlist_find_node(*ptrlist, ptr);
     
     if(node==NULL)
-        return FALSE;
+        return ptrlist_insert_last(ptrlist, ptr);
     
     UNLINK_ITEM(*ptrlist, node, next, prev);
     LINK_ITEM_LAST(*ptrlist, node, next, prev);
@@ -98,7 +104,7 @@
     PtrList *node=ptrlist_find_node(*ptrlist, ptr);
     
     if(node==NULL)
-        return FALSE;
+        return ptrlist_insert_first(ptrlist, ptr);
     
     UNLINK_ITEM(*ptrlist, node, next, prev);
     LINK_ITEM_FIRST(*ptrlist, node, next, prev);

mercurial