From cec22ba8db7c2400f3a6ab4f50c26baf8f44d455 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 20 Nov 2020 11:00:51 -0500 Subject: Cleanup: Use LISTBASE_FOREACH macro --- source/blender/editors/space_node/space_node.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'source/blender/editors/space_node') 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); } } -- cgit v1.2.3