From 38d1e7d79e438aebcaf85d17c7290a741982ccfb Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 16 Jan 2022 14:00:51 -0800 Subject: [PATCH] mingle genBundleColors: replace a 'unique_ptr' with a 'vector' When the `std::unique_ptr` usage was added here in 869891f9c87b326ddef4de461b92de98ec647b82, I was incorrectly too focused on preserving the previous property of this being a heap-allocated array. This is not necessary, and using a `std::vector` instead allows more flexibility. E.g. depending on the `std::vector` implementation, it could choose to allocate this array on the stack instead of the heap. --- cmd/mingle/minglemain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/mingle/minglemain.cpp b/cmd/mingle/minglemain.cpp index 7f2c88da3..42f1990aa 100644 --- a/cmd/mingle/minglemain.cpp +++ b/cmd/mingle/minglemain.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -301,7 +302,7 @@ static void genBundleColors(pedge edge, std::ostream &os, double maxwgt) { double len, t, len_total0 = 0; int dim = edge->dim; double* x = edge->x; - std::unique_ptr lens(new double[edge->npoints]); + std::vector lens(edge->npoints); for (j = 0; j < edge->npoints - 1; j++){ len = 0; -- 2.40.0