[Bf-blender-cvs] [cec22ba8db7] master: Cleanup: Use LISTBASE_FOREACH macro

Hans Goudey noreply at git.blender.org
Fri Nov 20 17:00:59 CET 2020


Commit: cec22ba8db7c2400f3a6ab4f50c26baf8f44d455
Author: Hans Goudey
Date:   Fri Nov 20 11:00:51 2020 -0500
Branches: master
https://developer.blender.org/rBcec22ba8db7c2400f3a6ab4f50c26baf8f44d455

Cleanup: Use LISTBASE_FOREACH macro

===================================================================

M	source/blender/editors/space_node/space_node.c

===================================================================

diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index d2502e6408c..76c25799e2c 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -168,10 +168,9 @@ bNodeTree *ED_node_tree_get(SpaceNode *snode, int level)
 
 int ED_node_tree_path_length(SpaceNode *snode)
 {
-  bNodeTreePath *path;
   int length = 0;
-  int i;
-  for (path = snode->treepath.first, i = 0; path; path = path->next, i++) {
+  int i = 0;
+  LISTBASE_FOREACH_INDEX (bNodeTreePath *, path, &snode->treepath, i) {
     length += strlen(path->node_name);
     if (i > 0) {
       length += 1; /* for separator char */
@@ -182,11 +181,10 @@ int ED_node_tree_path_length(SpaceNode *snode)
 
 void ED_node_tree_path_get(SpaceNode *snode, char *value)
 {
-  bNodeTreePath *path;
-  int i;
+  int i = 0;
 
   value[0] = '\0';
-  for (path = snode->treepath.first, i = 0; path; path = path->next, i++) {
+  LISTBASE_FOREACH_INDEX (bNodeTreePath *, path, &snode->treepath, i) {
     if (i == 0) {
       strcpy(value, path->node_name);
       value += strlen(path->node_name);
@@ -200,11 +198,11 @@ void ED_node_tree_path_get(SpaceNode *snode, char *value)
 
 void ED_node_tree_path_get_fixedbuf(SpaceNode *snode, char *value, int max_length)
 {
-  bNodeTreePath *path;
-  int size, i;
+  int size;
 
   value[0] = '\0';
-  for (path = snode->treepath.first, i = 0; path; path = path->next, i++) {
+  int i = 0;
+  LISTBASE_FOREACH_INDEX (bNodeTreePath *, path, &snode->treepath, i) {
     if (i == 0) {
       size = BLI_strncpy_rlen(value, path->node_name, max_length);
     }
@@ -319,10 +317,8 @@ static SpaceLink *node_create(const ScrArea *UNUSED(area), const Scene *UNUSED(s
 static void node_free(SpaceLink *sl)
 {
   SpaceNode *snode = (SpaceNode *)sl;
-  bNodeTreePath *path, *path_next;
 
-  for (path = snode->treepath.first; path; path = path_next) {
-    path_next = path->next;
+  LISTBASE_FOREACH_MUTABLE (bNodeTreePath *, path, &snode->treepath) {
     MEM_freeN(path);
   }
 }



More information about the Bf-blender-cvs mailing list