]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/dlist.c
Pool + label cleanups from bug reports
[bacula/bacula] / bacula / src / lib / dlist.c
index 5fe1b4e529d75abd85ecacd4a329320a9c686272..74f9fe7131985989eb734c517f82dde7b5932800 100644 (file)
@@ -103,10 +103,13 @@ void dlist::insert_after(void *item, void *where)
 }
 
 /*
+ *  Insert an item in the list, but only if it is unique
+ *  otherwise, the item is returned non inserted
+ *
  * Returns: item        if item inserted
  *         other_item   if same value already exists (item not inserted)
  */
-void *dlist::binary_insert(void *item, int compare(void *item1, void *item2))
+void *dlist::unique_binary_insert(void *item, int compare(void *item1, void *item2))
 {
    int comp;
    int low, high, cur;
@@ -197,6 +200,20 @@ void *dlist::binary_insert(void *item, int compare(void *item1, void *item2))
 }
 
 
+/*
+ *  Insert an item in the list, regardless if it is unique
+ *  or not.
+ */
+void dlist::binary_insert(void *item, int compare(void *item1, void *item2))
+{
+   void *ins_item = unique_binary_insert(item, compare);
+   /* If identical, insert after the one found */
+   if (ins_item != item) {
+      insert_after(item, ins_item);
+   }
+}
+
+
 void dlist::remove(void *item)
 {
    void *xitem;