]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/dlist.h
Ignore UTF-8 marker at the start of .conf files.
[bacula/bacula] / bacula / src / lib / dlist.h
index 7dd1b175620cea54ad79d99b472f04c3c5afbd50..2644158ef8d5ee78e6bea40cccbebf629dd6434f 100644 (file)
@@ -2,11 +2,11 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2004-2005 Kern Sibbald
+   Copyright (C) 2004-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
-   version 2 as ammended with additional clauses defined in the
+   version 2 as amended with additional clauses defined in the
    file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
@@ -28,7 +28,7 @@
 #define M_ABORT 1
 
 /* In case you want to specifically specify the offset to the link */
-#define OFFSET(item, link) ((char *)(link) - (char *)(item))
+#define OFFSET(item, link) (int)((char *)(link) - (char *)(item))
 /*
  * There is a lot of extra casting here to work around the fact
  * that some compilers (Sun and Visual C++) do not accept
  *
  * Loop var through each member of list
  */
+#ifdef HAVE_TYPEOF
 #define foreach_dlist(var, list) \
-    for((var)=NULL; (*((void **)&(var))=(void*)((list)->next(var))); )
-
-#ifdef the_old_way
+        for((var)=NULL; ((var)=(typeof(var))(list)->next(var)); )
+#else
 #define foreach_dlist(var, list) \
-        for((var)=NULL; (((void *)(var))=(list)->next(var)); )
+    for((var)=NULL; (*((void **)&(var))=(void*)((list)->next(var))); )
 #endif
 
 
+
 struct dlink {
    void *next;
    void *prev;
@@ -64,8 +65,9 @@ public:
    void append(void *item);
    void insert_before(void *item, void *where);
    void insert_after(void *item, void *where);
-   void *unique_binary_insert(void *item, int compare(void *item1, void *item2));
-   void binary_insert(void *item, int compare(void *item1, void *item2));
+   void *binary_insert(void *item, int compare(void *item1, void *item2));
+   void *binary_search(void *item, int compare(void *item1, void *item2));
+   void binary_insert_multiple(void *item, int compare(void *item1, void *item2));
    void remove(void *item);
    bool empty() const;
    int  size() const;
@@ -85,7 +87,7 @@ public:
 inline void dlist::init(void *item, dlink *link)
 {
    head = tail = NULL;
-   loffset = (char *)link - (char *)item;
+   loffset = (int)((char *)link - (char *)item);
    if (loffset < 0 || loffset > 5000) {
       Emsg0(M_ABORT, 0, "Improper dlist initialization.\n");
    }