diff options
author | Matt Turner <mattst88@gmail.com> | 2014-06-24 16:32:29 -0700 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2014-07-01 08:55:51 -0700 |
commit | da9f0316e6ea628c085040a0c145580301207489 (patch) | |
tree | fb4a5e768c5e3b087e891b28660360c9038f42cd /src/glsl | |
parent | 35976810405cedaf49151151d10c52e19636d684 (diff) | |
download | external_mesa3d-da9f0316e6ea628c085040a0c145580301207489.zip external_mesa3d-da9f0316e6ea628c085040a0c145580301207489.tar.gz external_mesa3d-da9f0316e6ea628c085040a0c145580301207489.tar.bz2 |
glsl: Add typed foreach_in_list_safe macro.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/list.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/glsl/list.h b/src/glsl/list.h index 914ce96..a4c6408 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -584,6 +584,15 @@ inline void exec_node::insert_before(exec_list *before) (__inst) = (__type *)(__inst)->prev) /** + * This version is safe even if the current node is removed. + */ +#define foreach_in_list_safe(__type, __node, __list) \ + for (__type *__node = (__type *)(__list)->head, \ + *__next = (__type *)__node->next; \ + __next != NULL; \ + __node = __next, __next = (__type *)__next->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. |