Fix exec_list::move_nodes_to when the source list is empty
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 1 Apr 2010 01:15:50 +0000 (18:15 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 1 Apr 2010 01:15:50 +0000 (18:15 -0700)
list.h

diff --git a/list.h b/list.h
index 33b038ce8daf2ea16032f99c7ada0b2e6f5c3f55..054be7ed4354f38e4af828a74e07e41767258a67 100644 (file)
--- a/list.h
+++ b/list.h
@@ -273,14 +273,18 @@ struct exec_list {
     */
    void move_nodes_to(exec_list *target)
    {
-      target->head = head;
-      target->tail = NULL;
-      target->tail_pred = tail_pred;
-
-      target->head->prev = (exec_node *) &target->head;
-      target->tail_pred->next = (exec_node *) &target->tail;
-
-      make_empty();
+      if (is_empty()) {
+        target->make_empty();
+      } else {
+        target->head = head;
+        target->tail = NULL;
+        target->tail_pred = tail_pred;
+
+        target->head->prev = (exec_node *) &target->head;
+        target->tail_pred->next = (exec_node *) &target->tail;
+
+        make_empty();
+      }
    }
 
    exec_list_iterator iterator()