exec_list: Add method to append one complete list to another
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 7 Jul 2010 19:12:48 +0000 (12:12 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 7 Jul 2010 19:41:26 +0000 (12:41 -0700)
src/glsl/list.h

index d449bdd8b12828d7cc7076ee70193a21ff0c4c4e..b5a413dc51105e2980ab9abadc13c99dc6980c9f 100644 (file)
@@ -385,6 +385,30 @@ struct exec_list {
       }
    }
 
+   /**
+    * Append all nodes from the source list to the target list
+    */
+   void
+   append_list(exec_list *source)
+   {
+      if (source->is_empty())
+        return;
+
+      /* Link the first node of the source with the last node of the target list.
+       */
+      this->tail_pred->next = source->head;
+      source->head->prev = this->tail_pred;
+
+      /* Make the tail of the source list be the tail of the target list.
+       */
+      this->tail_pred = source->tail_pred;
+      this->tail_pred->next = (exec_node *) &this->tail;
+
+      /* Make the source list empty for good measure.
+       */
+      source->make_empty();
+   }
+
    exec_list_iterator iterator()
    {
       return exec_list_iterator(head);