]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/alist.h
19July06
[bacula/bacula] / bacula / src / lib / alist.h
index c4727e8ab54b6d572e17defb891c63b2fce4c21e..dcdf809d4f171692008f61035521870a2aa14701 100644 (file)
@@ -4,7 +4,7 @@
  *  Kern Sibbald, June MMIII
  */
 /*
-   Copyright (C) 2003-2005 Kern Sibbald
+   Copyright (C) 2003-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
  *
  * Loop var through each member of list
  */
+#ifdef HAVE_TYPEOF
+#define foreach_alist(var, list) \
+        for((var)=(typeof(var))(list)->first(); (var); (var)=(typeof(var))(list)->next() )
+#else
 #define foreach_alist(var, list) \
     for((*((void **)&(var))=(void*)((list)->first())); \
          (var); \
          (*((void **)&(var))=(void*)((list)->next())))
-
-#ifdef the_easy_way
-#define foreach_alist(var, list) \
-        for(((void*)(var))=(list)->first(); (var); ((void*)(var))=(list)->next(var)); )
 #endif
 
 
+
 /* Second arg of init */
 enum {
   owned_by_alist = true,
@@ -75,7 +76,7 @@ public:
 
    /* Use it as a stack, pushing and poping from the end */
    void push(void *item) { append(item); };
-   void pop() { num_items?NULL:remove(num_items-1); };
+   void *pop() { return remove(num_items-1); };
 };
 
 inline void * alist::operator [](int index) const {