From aaff37d3aadd2a7d689ed9d2818594a41eab4e58 Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Thu, 9 Nov 2023 07:11:35 -0800 Subject: [PATCH] Update VectorInterpolator destructor --- lib/algo/manifold_interp/VectorInterpolator.cpp | 14 ++++++++++++-- lib/algo/manifold_interp/VectorInterpolator.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/algo/manifold_interp/VectorInterpolator.cpp b/lib/algo/manifold_interp/VectorInterpolator.cpp index 57da10145..c009d3034 100644 --- a/lib/algo/manifold_interp/VectorInterpolator.cpp +++ b/lib/algo/manifold_interp/VectorInterpolator.cpp @@ -61,19 +61,29 @@ VectorInterpolator::VectorInterpolator(std::vector parameter_points, if (i == d_ref_point) { d_rotated_reduced_vectors.push_back(reduced_vectors[i]); + d_rotated_reduced_vectors_owned.push_back(false); } else { Vector* Q_tA = rotation_matrices[i]->transposeMult(reduced_vectors[i]); d_rotated_reduced_vectors.push_back(Q_tA); + d_rotated_reduced_vectors_owned.push_back(true); } } } VectorInterpolator::~VectorInterpolator() { - for (auto v : d_rotated_reduced_vectors) - delete v; + CAROM_VERIFY(d_rotated_reduced_vectors.size() == + d_rotated_reduced_vectors_owned.size()); + + for (int i = 0; i < d_rotated_reduced_vectors.size(); i++) + { + if (d_rotated_reduced_vectors_owned[i]) + { + delete d_rotated_reduced_vectors[i]; + } + } for (auto v : d_gammas) delete v; diff --git a/lib/algo/manifold_interp/VectorInterpolator.h b/lib/algo/manifold_interp/VectorInterpolator.h index b8e141268..674b083f2 100644 --- a/lib/algo/manifold_interp/VectorInterpolator.h +++ b/lib/algo/manifold_interp/VectorInterpolator.h @@ -110,6 +110,8 @@ class VectorInterpolator : public Interpolator */ std::vector d_rotated_reduced_vectors; + std::vector d_rotated_reduced_vectors_owned; + /** * @brief The reduced elements in tangential space. */