[Bf-blender-cvs] [115ff08fdb2] master: Fix: Use "construct" instead of "assign" for uninitialized memory

Hans Goudey noreply at git.blender.org
Wed Mar 9 17:23:30 CET 2022


Commit: 115ff08fdb251cf0a656ce729c49ac38d96cd5f9
Author: Hans Goudey
Date:   Wed Mar 9 10:23:17 2022 -0600
Branches: master
https://developer.blender.org/rB115ff08fdb251cf0a656ce729c49ac38d96cd5f9

Fix: Use "construct" instead of "assign" for uninitialized memory

The realize instances code used "assign", but the attribute buffers on
the result aren't necessarily initialized. This doesn't make a difference
for trivial types like `int`, but it would with more complex types.

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

M	source/blender/geometry/intern/realize_instances.cc

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

diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc
index c2337c37d1f..9acabae10ab 100644
--- a/source/blender/geometry/intern/realize_instances.cc
+++ b/source/blender/geometry/intern/realize_instances.cc
@@ -646,7 +646,7 @@ static void execute_realize_pointcloud_task(const RealizeInstancesOptions &optio
             const GSpan src_span = *pointcloud_info.attributes[attribute_index];
             threading::parallel_for(
                 IndexRange(pointcloud.totpoint), 1024, [&](const IndexRange range) {
-                  cpp_type.copy_assign_n(
+                  cpp_type.copy_construct_n(
                       src_span.slice(range).data(), dst_span.slice(range).data(), range.size());
                 });
           }
@@ -657,7 +657,7 @@ static void execute_realize_pointcloud_task(const RealizeInstancesOptions &optio
             /* As the fallback value for the attribute. */
             threading::parallel_for(
                 IndexRange(pointcloud.totpoint), 1024, [&](const IndexRange range) {
-                  cpp_type.fill_assign_n(
+                  cpp_type.fill_construct_n(
                       attribute_fallback, dst_span.slice(range).data(), range.size());
                 });
           }
@@ -943,9 +943,9 @@ static void execute_realize_mesh_task(const RealizeInstancesOptions &options,
             const GSpan src_span = *mesh_info.attributes[attribute_index];
             threading::parallel_for(
                 IndexRange(element_slice.size()), 1024, [&](const IndexRange sub_range) {
-                  cpp_type.copy_assign_n(src_span.slice(sub_range).data(),
-                                         dst_span.slice(sub_range).data(),
-                                         sub_range.size());
+                  cpp_type.copy_construct_n(src_span.slice(sub_range).data(),
+                                            dst_span.slice(sub_range).data(),
+                                            sub_range.size());
                 });
           }
           else {
@@ -954,7 +954,7 @@ static void execute_realize_mesh_task(const RealizeInstancesOptions &options,
             }
             threading::parallel_for(
                 IndexRange(element_slice.size()), 1024, [&](const IndexRange sub_range) {
-                  cpp_type.fill_assign_n(
+                  cpp_type.fill_construct_n(
                       attribute_fallback, dst_span.slice(sub_range).data(), sub_range.size());
                 });
           }
@@ -1251,9 +1251,9 @@ static void execute_realize_curve_task(const RealizeInstancesOptions &options,
             const GSpan src_span = *curves_info.attributes[attribute_index];
             threading::parallel_for(
                 IndexRange(element_slice.size()), 1024, [&](const IndexRange sub_range) {
-                  cpp_type.copy_assign_n(src_span.slice(sub_range).data(),
-                                         dst_span.slice(sub_range).data(),
-                                         sub_range.size());
+                  cpp_type.copy_construct_n(src_span.slice(sub_range).data(),
+                                            dst_span.slice(sub_range).data(),
+                                            sub_range.size());
                 });
           }
           else {
@@ -1262,7 +1262,7 @@ static void execute_realize_curve_task(const RealizeInstancesOptions &options,
             }
             threading::parallel_for(
                 IndexRange(element_slice.size()), 1024, [&](const IndexRange sub_range) {
-                  cpp_type.fill_assign_n(
+                  cpp_type.fill_construct_n(
                       attribute_fallback, dst_span.slice(sub_range).data(), sub_range.size());
                 });
           }



More information about the Bf-blender-cvs mailing list