objlist.c

changeset 111
7d1dccdd7215
parent 101
50525dab6c8e
--- a/objlist.c	Tue Apr 24 19:00:47 2007 +0200
+++ b/objlist.c	Sun May 06 16:05:59 2007 +0200
@@ -136,6 +136,12 @@
 }
 
 
+bool objlist_contains(ObjList *objlist, Obj *obj)
+{
+    return (objlist_find_node(objlist, obj)!=NULL);
+}
+
+
 bool objlist_insert_last(ObjList **objlist, Obj *obj)
 {
     ObjList *node=reuse(objlist);
@@ -177,7 +183,7 @@
     node=objlist_find_node(*objlist, obj);
     
     if(node==NULL)
-        return FALSE;
+        return objlist_insert_last(objlist, obj);
     
     UNLINK_ITEM(*objlist, node, next, prev);
     LINK_ITEM_LAST(*objlist, node, next, prev);
@@ -195,7 +201,7 @@
     node=objlist_find_node(*objlist, obj);
     
     if(node==NULL)
-        return FALSE;
+        return objlist_insert_first(objlist, obj);
     
     UNLINK_ITEM(*objlist, node, next, prev);
     LINK_ITEM_FIRST(*objlist, node, next, prev);

mercurial