util: Move ralloc to a new src/util directory.
[mesa.git] / src / glsl / list.h
index 66028f649d43a24e9b74badba692f5dc110b605f..b6c32bcccaf5b8569d748fb5b8ca6867c9048732 100644 (file)
@@ -69,7 +69,7 @@
 #endif
 #include <assert.h>
 
-#include "ralloc.h"
+#include "util/ralloc.h"
 
 struct exec_node {
    struct exec_node *next;
@@ -325,6 +325,8 @@ struct exec_list {
    const exec_node *get_tail() const;
    exec_node *get_tail();
 
+   unsigned length() const;
+
    void push_head(exec_node *n);
    void push_tail(exec_node *n);
    void push_degenerate_list_at_head(exec_node *n);
@@ -405,6 +407,19 @@ exec_list_get_tail(struct exec_list *list)
    return !exec_list_is_empty(list) ? list->tail_pred : NULL;
 }
 
+static inline unsigned
+exec_list_length(const struct exec_list *list)
+{
+   unsigned size = 0;
+   struct exec_node *node;
+
+   for (node = list->head; node->next != NULL; node = node->next) {
+      size++;
+   }
+
+   return size;
+}
+
 static inline void
 exec_list_push_head(struct exec_list *list, struct exec_node *n)
 {
@@ -537,6 +552,11 @@ inline exec_node *exec_list::get_tail()
    return exec_list_get_tail(this);
 }
 
+inline unsigned exec_list::length() const
+{
+   return exec_list_length(this);
+}
+
 inline void exec_list::push_head(exec_node *n)
 {
    exec_list_push_head(this, n);