diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-09-18 07:52:16 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:51:59 -0500 |
commit | 2f58645b7094e81dff3734f11aa183ea2ab53d2d (patch) | |
tree | c5c65611d18a60dd3612d2466a45d2b36dc4167a /source/include | |
parent | a52fa218952ffcd784ea31e947aa4d17dfdc8ee0 (diff) | |
download | samba-2f58645b7094e81dff3734f11aa183ea2ab53d2d.tar.gz samba-2f58645b7094e81dff3734f11aa183ea2ab53d2d.tar.xz samba-2f58645b7094e81dff3734f11aa183ea2ab53d2d.zip |
r18605: sync dlinklist.h with samba4, that means DLIST_ADD_END()
and DLIST_DEMOTE() now take the type of the tmp pointer
not the tmp pointer itself anymore.
metze
Diffstat (limited to 'source/include')
-rw-r--r-- | source/include/dlinklist.h | 60 |
1 files changed, 41 insertions, 19 deletions
diff --git a/source/include/dlinklist.h b/source/include/dlinklist.h index daec7640e40..f267e77ea6d 100644 --- a/source/include/dlinklist.h +++ b/source/include/dlinklist.h @@ -21,10 +21,13 @@ /* To use these macros you must have a structure containing a next and prev pointer */ +#ifndef _DLINKLIST_H +#define _DLINKLIST_H + /* hook into the front of the list */ #define DLIST_ADD(list, p) \ -{ \ +do { \ if (!(list)) { \ (list) = (p); \ (p)->next = (p)->prev = NULL; \ @@ -34,11 +37,11 @@ (p)->prev = NULL; \ (list) = (p); \ }\ -} +} while (0) /* remove an element from a list - element doesn't have to be in list. */ #define DLIST_REMOVE(list, p) \ -{ \ +do { \ if ((p) == (list)) { \ (list) = (p)->next; \ if (list) (list)->prev = NULL; \ @@ -47,28 +50,29 @@ if ((p)->next) (p)->next->prev = (p)->prev; \ } \ if ((p) != (list)) (p)->next = (p)->prev = NULL; \ -} +} while (0) /* promote an element to the top of the list */ #define DLIST_PROMOTE(list, p) \ -{ \ - DLIST_REMOVE(list, p) \ - DLIST_ADD(list, p) \ -} +do { \ + DLIST_REMOVE(list, p); \ + DLIST_ADD(list, p); \ +} while (0) /* hook into the end of the list - needs a tmp pointer */ -#define DLIST_ADD_END(list, p, tmp) \ -{ \ +#define DLIST_ADD_END(list, p, type) \ +do { \ if (!(list)) { \ (list) = (p); \ (p)->next = (p)->prev = NULL; \ } else { \ - for ((tmp) = (list); (tmp)->next; (tmp) = (tmp)->next) ; \ - (tmp)->next = (p); \ + type tmp; \ + for (tmp = (list); tmp->next; tmp = tmp->next) ; \ + tmp->next = (p); \ (p)->next = NULL; \ - (p)->prev = (tmp); \ + (p)->prev = tmp; \ } \ -} +} while (0) /* insert 'p' after the given element 'el' in a list. If el is NULL then this is the same as a DLIST_ADD() */ @@ -84,9 +88,27 @@ do { \ }\ } while (0) -/* demote an element to the top of the list, needs a tmp pointer */ +/* demote an element to the end of the list, needs a tmp pointer */ #define DLIST_DEMOTE(list, p, tmp) \ -{ \ - DLIST_REMOVE(list, p) \ - DLIST_ADD_END(list, p, tmp) \ -} +do { \ + DLIST_REMOVE(list, p); \ + DLIST_ADD_END(list, p, tmp); \ +} while (0) + +/* concatenate two lists - putting all elements of the 2nd list at the + end of the first list */ +#define DLIST_CONCATENATE(list1, list2, type) \ +do { \ + if (!(list1)) { \ + (list1) = (list2); \ + } else { \ + type tmp; \ + for (tmp = (list1); tmp->next; tmp = tmp->next) ; \ + tmp->next = (list2); \ + if (list2) { \ + (list2)->prev = tmp; \ + } \ + } \ +} while (0) + +#endif /* _DLINKLIST_H */ |