diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-10-31 00:34:46 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-10-31 00:34:46 +0300 |
commit | 16f06e9dc9f9fe5fa05a3ad60bd29641c5ab4de7 (patch) | |
tree | 5222dd8f49b70586ee56fa04e777b796f3d47a41 | |
parent | 7aabe3f66cae3c57ca37842acfd7d002dcae023f (diff) |
Introduce "skip" in BLI_Iterator struct
This helps iterators prevent recursion.
-rw-r--r-- | source/blender/blenlib/BLI_iterator.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/blenlib/BLI_iterator.h b/source/blender/blenlib/BLI_iterator.h index a2ec21d89b3..39d5cc12d87 100644 --- a/source/blender/blenlib/BLI_iterator.h +++ b/source/blender/blenlib/BLI_iterator.h @@ -30,6 +30,7 @@ typedef struct BLI_Iterator { void *current; /* current pointer we iterate over */ void *data; /* stored data required for this iterator */ + bool skip; bool valid; } BLI_Iterator; @@ -40,12 +41,18 @@ typedef void (*IteratorBeginCb)(BLI_Iterator *iter, void *data_in); { \ _type _instance; \ IteratorCb callback_end_func = callback_end; \ - BLI_Iterator iter_macro; \ + BLI_Iterator iter_macro = { \ + .skip = false, \ + }; \ for (callback_begin(&iter_macro, (_data_in)); \ iter_macro.valid; \ callback_next(&iter_macro)) \ - { \ - _instance = (_type ) iter_macro.current; + { \ + if (iter_macro.skip) { \ + iter_macro.skip = false; \ + continue; \ + } \ + _instance = (_type ) iter_macro.current; #define ITER_END \ } \ |