list_move

Stefan Dösinger stefandoesinger at gmx.at
Mon Dec 4 09:12:58 CST 2006


This is an updated version of my list_move patch from saturday with the 
suggestions from aj:

*list_head and list_tail aren't used any more
*renamed list_move to list_move_tail and added list_move_head to attach the 
source to the end / beginning of the destination list.
-------------- next part --------------
From 1cfaa924a542d65d794f921ae32d1c0467e99855 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Mon, 4 Dec 2006 15:27:24 +0100
Subject: [PATCH] list_move

---
 include/wine/list.h |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/include/wine/list.h b/include/wine/list.h
index 6ceef8c..f0c4301 100644
--- a/include/wine/list.h
+++ b/include/wine/list.h
@@ -139,6 +139,33 @@ inline static void list_init( struct lis
     list->next = list->prev = list;
 }
 
+/* Move all ements from a list to another */
+inline static void list_move_tail(struct list *dst, struct list *src)
+{
+    if(list_empty(src)) return;
+
+    dst->prev->next = src->next;
+    src->next->prev = dst->prev;
+    dst->prev = src->prev;
+    src->prev->next = dst;
+
+    /* Get the source to a sane state */
+    list_init(src);
+}
+
+inline static void list_move_head(struct list *dst, struct list *src)
+{
+    if(list_empty(src)) return;
+
+    dst->prev->next = src->next;
+    src->next->prev = dst->prev;
+    dst->prev = src->prev;
+    src->prev->next = dst;
+
+    /* Get the source to a sane state */
+    list_init(src);
+}
+
 /* iterate through the list */
 #define LIST_FOR_EACH(cursor,list) \
     for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->next)
-- 
1.4.2.4



More information about the wine-patches mailing list