X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglsl%2Flist.h;h=f9eb60ec7c4f07d6dbe428341d759252172cd5be;hb=48d0faaa4388f411ea64fef8f4be04c22d02a4cf;hp=3197b03cf2832a51fd9044e72f9debb55f33cb8f;hpb=26fe16a99b762d27e8f499c2e02116e9c4b7a6bb;p=mesa.git diff --git a/src/glsl/list.h b/src/glsl/list.h index 3197b03cf28..f9eb60ec7c4 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -66,38 +66,17 @@ #ifndef __cplusplus #include -#include -#else -extern "C" { -#include -} #endif - #include +#include "ralloc.h" + struct exec_node { struct exec_node *next; struct exec_node *prev; #ifdef __cplusplus - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = talloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. */ - static void operator delete(void *node) - { - talloc_free(node); - } + DECLARE_RALLOC_CXX_OPERATORS(exec_node) exec_node() : next(NULL), prev(NULL) { @@ -289,24 +268,7 @@ struct exec_list { struct exec_node *tail_pred; #ifdef __cplusplus - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = talloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. */ - static void operator delete(void *node) - { - talloc_free(node); - } + DECLARE_RALLOC_CXX_OPERATORS(exec_list) exec_list() { @@ -485,6 +447,22 @@ inline void exec_node::insert_before(exec_list *before) ; (__node)->next != NULL \ ; (__node) = (__node)->next) +/** + * Iterate through two lists at once. Stops at the end of the shorter list. + * + * This is safe against either current node being removed or replaced. + */ +#define foreach_two_lists(__node1, __list1, __node2, __list2) \ + for (exec_node * __node1 = (__list1)->head, \ + * __node2 = (__list2)->head, \ + * __next1 = __node1->next, \ + * __next2 = __node2->next \ + ; __next1 != NULL && __next2 != NULL \ + ; __node1 = __next1, \ + __node2 = __next2, \ + __next1 = __next1->next, \ + __next2 = __next2->next) + #define foreach_list_const(__node, __list) \ for (const exec_node * __node = (__list)->head \ ; (__node)->next != NULL \