diff options
author | Sam Kottler <dev@samkottler.net> | 2020-08-20 19:40:02 +0300 |
---|---|---|
committer | Sam Kottler <dev@samkottler.net> | 2020-08-20 19:40:02 +0300 |
commit | 9dd50b39a433dc09b634d70ca8533ad19b4d1d5e (patch) | |
tree | 96341c40a13f620aa7f6a92fd6783dc6883216b0 /source/blender/blenlib/BLI_listbase.h | |
parent | 35624cdfe5186ee916e4519a013ef5c078d9c667 (diff) | |
parent | c74b4caa724bf74de41ba3928cdd824aa9ba59d2 (diff) |
Merge remote-tracking branch 'origin/blender-v2.90-release' into soc-2020-production-ready-light-tree-2soc-2020-production-ready-light-tree-2
Diffstat (limited to 'source/blender/blenlib/BLI_listbase.h')
-rw-r--r-- | source/blender/blenlib/BLI_listbase.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h index fa7cf7a1847..932b63e43f7 100644 --- a/source/blender/blenlib/BLI_listbase.h +++ b/source/blender/blenlib/BLI_listbase.h @@ -186,6 +186,14 @@ struct LinkData *BLI_genericNodeN(void *data); ((var != NULL) ? ((void)(var##_iter_prev = (type)(((Link *)(var))->prev)), 1) : 0); \ var = var##_iter_prev) +/** + * A version of #LISTBASE_FOREACH that takes an index variable (declared outside this macro). + * This avoids possible accidents where using `continue` could miss incrementing the counter. + */ +#define LISTBASE_FOREACH_INDEX(type, var, list, index_var) \ + for (type var = (((void)(index_var = 0)), (type)((list)->first)); var != NULL; \ + var = (type)(((Link *)(var))->next), index_var++) + #ifdef __cplusplus } #endif |