From c294df619656798b107933a42a0f5613c1df0830 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Tue, 15 Mar 2011 01:57:14 +0000 Subject: core: Add list_append_init To append to end of list, as compared to list_splice_init which prepends. Signed-off-by: Shehjar Tikoo Signed-off-by: Vijay Bellur BUG: 2491 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2491 --- libglusterfs/src/list.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/list.h b/libglusterfs/src/list.h index 886c4f273a1..52d98fc518d 100644 --- a/libglusterfs/src/list.h +++ b/libglusterfs/src/list.h @@ -120,6 +120,7 @@ list_splice (struct list_head *list, struct list_head *head) } +/* Splice moves @list to the head of the list at @head. */ static inline void list_splice_init (struct list_head *list, struct list_head *head) { @@ -131,6 +132,38 @@ list_splice_init (struct list_head *list, struct list_head *head) } +static inline void +__list_append (struct list_head *list, struct list_head *head) +{ + (head->prev)->next = (list->next); + (list->next)->prev = (head->prev); + (head->prev) = (list->prev); + (list->prev)->next = head; +} + + +static inline void +list_append (struct list_head *list, struct list_head *head) +{ + if (list_empty (list)) + return; + + __list_append (list, head); +} + + +/* Append moves @list to the end of @head */ +static inline void +list_append_init (struct list_head *list, struct list_head *head) +{ + if (list_empty (list)) + return; + + __list_append (list, head); + INIT_LIST_HEAD (list); +} + + #define list_entry(ptr, type, member) \ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) -- cgit