summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2011-03-15 01:57:14 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-31 04:19:35 -0700
commitc294df619656798b107933a42a0f5613c1df0830 (patch)
tree5ca6b350c9dc5a229e8da101f744cf67bd5a38c1 /libglusterfs
parenta54e0358b1d66c04448b22c1a01e076b5a527008 (diff)
core: Add list_append_init
To append to end of list, as compared to list_splice_init which prepends. Signed-off-by: Shehjar Tikoo <shehjart@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2491 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2491
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/list.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/libglusterfs/src/list.h b/libglusterfs/src/list.h
index 886c4f273..52d98fc51 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)))