# HG changeset patch # User Tuomo Valkonen # Date 1109455851 -3600 # Node ID 5f72042eb91c1667452e511fe5cc1fef47696721 # Parent 55fcdff5bcea668a8da0406fb78501c699961327 Increased FOR_ALL macro reuse. diff -r 55fcdff5bcea -r 5f72042eb91c objlist.h --- a/objlist.h Sat Feb 26 22:09:33 2005 +0100 +++ b/objlist.h Sat Feb 26 23:10:51 2005 +0100 @@ -12,6 +12,7 @@ #include "types.h" #include "obj.h" +#include "ptrlist.h" INTRSTRUCT(ObjList); @@ -31,16 +32,11 @@ #define OBJLIST_EMPTY(LIST) objlist_empty(LIST) #define FOR_ALL_ON_OBJLIST(TYPE, VAR, LL, TMP) \ - for(objlist_iter_init(&(TMP), LL), \ - VAR=(TYPE)objlist_iter(&(TMP)); \ - VAR!=NULL; \ - VAR=(TYPE)objlist_iter(&(TMP))) + FOR_ALL_ITER(objlist_iter_init, (TYPE)objlist_iter, VAR, LL, &(TMP)) -#define FOR_ALL_ON_OBJLIST_REV(TYPE, VAR, LL, TMP) \ - for(objlist_iter_rev_init(&(TMP), LL), \ - VAR=(TYPE)objlist_iter_rev(&(TMP)); \ - VAR!=NULL; \ - VAR=(TYPE)objlist_iter_rev(&(TMP))) +#define FOR_ALL_ON_OBJLIST_REV(TYPE, VAR, LL, TMP) \ + FOR_ALL_ITER(objlist_iter_rev_init, \ + (TYPE)objlist_iter_rev, VAR, LL, &(TMP)) #define FOR_ALL_ON_OBJLIST_UNSAFE(TYPE, VAR, LL) \ FOR_ALL_ON_OBJLIST(TYPE, VAR, LL, objlist_iter_tmp) diff -r 55fcdff5bcea -r 5f72042eb91c ptrlist.h --- a/ptrlist.h Sat Feb 26 22:09:33 2005 +0100 +++ b/ptrlist.h Sat Feb 26 23:10:51 2005 +0100 @@ -29,17 +29,15 @@ #define PTRLIST_LAST(TYPE, LL) ((LL)==NULL ? NULL : (TYPE)(LL)->prev->ptr) #define PTRLIST_EMPTY(LIST) ((LIST)==NULL) -#define FOR_ALL_ON_PTRLIST(TYPE, VAR, LL, TMP) \ - for(ptrlist_iter_init(&(TMP), LL), \ - VAR=(TYPE)ptrlist_iter(&(TMP)); \ - VAR!=NULL; \ - VAR=(TYPE)ptrlist_iter(&(TMP))) +#define FOR_ALL_ITER(INIT, ITER, VAR, LL, TMP) \ + for(INIT(TMP, LL), (VAR)=ITER(TMP); (VAR)!=NULL; VAR=ITER(TMP)) -#define FOR_ALL_ON_PTRLIST_REV(TYPE, VAR, LL, TMP) \ - for(ptrlist_iter_rev_init(&(TMP), LL), \ - VAR=(TYPE)ptrlist_iter_rev(&(TMP)); \ - VAR!=NULL; \ - VAR=(TYPE)ptrlist_iter_rev(&(TMP))) +#define FOR_ALL_ON_PTRLIST(TYPE, VAR, LL, TMP) \ + FOR_ALL_ITER(ptrlist_iter_init, (TYPE)ptrlist_iter, VAR, LL, &(TMP)) + +#define FOR_ALL_ON_PTRLIST_REV(TYPE, VAR, LL, TMP) \ + FOR_ALL_ITER(ptrlist_iter_rev_init, \ + (TYPE)ptrlist_iter_rev, VAR, LL, &(TMP)) #define FOR_ALL_ON_PTRLIST_UNSAFE(TYPE, VAR, LL) \ FOR_ALL_ON_PTRLIST(TYPE, VAR, LL, ptrlist_iter_tmp)