changeset 27776:881efe2c4c0f

avoid use of new/delete outside of constructor/destructor * graphics.cc (patch::properties::update_vertex_normals): Use std::vector<std::vector<T>> object instead of creating array of std::vector<T> objects with new that must be matched with delete. This way, memory for this object will be cleaned up when it goes out of scope even if that happens because an exception is thrown.
author John W. Eaton <jwe@octave.org>
date Thu, 05 Dec 2019 21:01:08 -0600
parents f47bb02c8d06
children 3b6920ee4383
files libinterp/corefcn/graphics.cc
diffstat 1 files changed, 1 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Thu Dec 05 21:21:51 2019 +0100
+++ b/libinterp/corefcn/graphics.cc	Thu Dec 05 21:01:08 2019 -0600
@@ -10123,7 +10123,7 @@
 
       // Second step: assign normals to the respective vertices
       // list of normals for vertices
-      std::vector<RowVector> *vec_vn = new std::vector<RowVector> [num_v];
+      std::vector<std::vector<RowVector>> vec_vn (num_v);
       for (octave_idx_type i = 0; i < num_f; i++)
         {
           // get number of corners
@@ -10178,8 +10178,6 @@
             }
         }
 
-      delete[] vec_vn;
-
       vertexnormals = vn;
     }
   else if (reset)