[Bf-blender-cvs] [c1b1ed4d5b2] master: Minor cleanup to `scene_collection_array`.

Bastien Montagne noreply at git.blender.org
Thu Apr 8 11:48:23 CEST 2021


Commit: c1b1ed4d5b2f90b48296055e817fded0f8ee8f38
Author: Bastien Montagne
Date:   Thu Apr 8 11:22:47 2021 +0200
Branches: master
https://developer.blender.org/rBc1b1ed4d5b2f90b48296055e817fded0f8ee8f38

Minor cleanup to `scene_collection_array`.

Use array allocation, and remove useless check.

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

M	source/blender/blenkernel/intern/collection.c

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

diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 426f8a44aff..8e4633cbe15 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -2015,12 +2015,10 @@ static void scene_collections_array(Scene *scene,
   BLI_assert(collection != NULL);
   scene_collection_callback(collection, scene_collections_count, r_collections_array_len);
 
-  if (*r_collections_array_len == 0) {
-    return;
-  }
+  BLI_assert(*r_collections_array_len > 0);
 
-  Collection **array = MEM_mallocN(sizeof(Collection *) * (*r_collections_array_len),
-                                   "CollectionArray");
+  Collection **array = MEM_malloc_arrayN(
+      *r_collections_array_len, sizeof(Collection *), "CollectionArray");
   *r_collections_array = array;
   scene_collection_callback(collection, scene_collections_build_array, &array);
 }



More information about the Bf-blender-cvs mailing list