Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-07-01 05:42:09 +0300
committerHans Goudey <h.goudey@me.com>2022-07-01 05:42:09 +0300
commit276e419671b31dde4f73c269e94c9e0d7d29708f (patch)
tree380dbdf6036ead59764990386c1643feafca7430 /source/blender/blenkernel/intern/curves_geometry.cc
parent7e55ff15b094079d8052c353fcc8aa7e1f6422c5 (diff)
Curves: Avoid initializing offsets when first allocated
The offsets array that encodes the sizes of each curve must be filled anyway, or the curves will be in an invalid state. Calloc is unnecessary here. To make that situation clearer, fill the offsets with -1 in debug builds. Always set the first offset to zero though, since that can save some boilerplate in other areas.
Diffstat (limited to 'source/blender/blenkernel/intern/curves_geometry.cc')
-rw-r--r--source/blender/blenkernel/intern/curves_geometry.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc
index b58781ce806..0326afca202 100644
--- a/source/blender/blenkernel/intern/curves_geometry.cc
+++ b/source/blender/blenkernel/intern/curves_geometry.cc
@@ -62,7 +62,11 @@ CurvesGeometry::CurvesGeometry(const int point_num, const int curve_num)
this->point_num,
ATTR_POSITION.c_str());
- this->curve_offsets = (int *)MEM_calloc_arrayN(this->curve_num + 1, sizeof(int), __func__);
+ this->curve_offsets = (int *)MEM_malloc_arrayN(this->curve_num + 1, sizeof(int), __func__);
+#ifdef DEBUG
+ this->offsets_for_write().fill(-1);
+#endif
+ this->offsets_for_write().first() = 0;
this->update_customdata_pointers();
@@ -84,7 +88,7 @@ static void copy_curves_geometry(CurvesGeometry &dst, const CurvesGeometry &src)
CustomData_copy(&src.curve_data, &dst.curve_data, CD_MASK_ALL, CD_DUPLICATE, dst.curve_num);
MEM_SAFE_FREE(dst.curve_offsets);
- dst.curve_offsets = (int *)MEM_calloc_arrayN(dst.point_num + 1, sizeof(int), __func__);
+ dst.curve_offsets = (int *)MEM_malloc_arrayN(dst.point_num + 1, sizeof(int), __func__);
dst.offsets_for_write().copy_from(src.offsets());
dst.tag_topology_changed();