From b7e99063370cf31145f07d68b8bf0d5c2d07de0e Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 12 Apr 2023 14:56:28 -0400 Subject: [PATCH] Cleanup: Remove unnecessary check when allocating mesh face offsets The assert already checks this, but even in release builds, doing nothing is probably worse than a memory leak here. --- source/blender/blenkernel/intern/mesh.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index e1d901bcdc2..3bad954f141 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -970,15 +970,15 @@ void BKE_mesh_poly_offsets_ensure_alloc(Mesh *mesh) if (mesh->totpoly == 0) { return; } - if (!mesh->poly_offset_indices) { - mesh->poly_offset_indices = static_cast( - MEM_malloc_arrayN(mesh->totpoly + 1, sizeof(int), __func__)); - } + mesh->poly_offset_indices = static_cast( + MEM_malloc_arrayN(mesh->totpoly + 1, sizeof(int), __func__)); + #ifdef DEBUG /* Fill offsets with obviously bad values to simplify finding missing initialization. */ mesh->poly_offsets_for_write().fill(-1); #endif - mesh->poly_offsets_for_write().last() = mesh->totloop; + mesh->poly_offset_indices[0] = 0; + mesh->poly_offset_indices[mesh->totpoly] = mesh->totloop; } static void mesh_ensure_cdlayers_primary(Mesh &mesh)