From: dlezcano Date: Tue, 9 Dec 2008 09:41:47 +0000 (+0000) Subject: Allows to enqueue list element instead of pushing on top of the list X-Git-Tag: lxc_0_5_1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da9e3794b55ee2d36a1e13e27830e4821ec25829;p=thirdparty%2Flxc.git Allows to enqueue list element instead of pushing on top of the list From: Daniel Lezcano Added the list_add_tail function to add an element at the end of the list. Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc_list.h b/src/lxc/lxc_list.h index 45c04fb1f..7dfd22bf0 100644 --- a/src/lxc/lxc_list.h +++ b/src/lxc/lxc_list.h @@ -7,7 +7,7 @@ struct lxc_list { struct lxc_list *prev; }; -#define lxc_init_list(l) { .next = l, .prev = l, } +#define lxc_init_list(l) { .next = l, .prev = l } #define lxc_list_for_each(__iterator, __list) \ for (__iterator = (__list)->next; \ @@ -35,13 +35,25 @@ static inline int lxc_list_empty(struct lxc_list *list) return list == list->next; } +static inline void __lxc_list_add(struct lxc_list *new, + struct lxc_list *prev, + struct lxc_list *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; +} + static inline void lxc_list_add(struct lxc_list *head, struct lxc_list *list) { - struct lxc_list *next = head->next; - next->prev = list; - list->next = next; - list->prev = head; - head->next = list; + __lxc_list_add(list, head, head->next); +} + +static inline void lxc_list_add_tail(struct lxc_list *head, + struct lxc_list *list) +{ + __lxc_list_add(list, head->prev, head); } static inline void lxc_list_del(struct lxc_list *list)