]> granicus.if.org Git - graphviz/commitdiff
mingle genBundleColors: avoid some manual memory management
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 25 Dec 2021 20:10:38 +0000 (12:10 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 4 Jan 2022 15:58:22 +0000 (07:58 -0800)
cmd/mingle/minglemain.cpp

index 6983d98c83c7d2c603131822120edec52143e23a..12caf5779b0fe3b7920f51cb5fa1a3774a77f58d 100644 (file)
@@ -15,6 +15,7 @@
 #include <common/pointset.h>
 #include <getopt.h>
 #include <iomanip>
+#include <memory>
 #include <sstream>
 #include <stddef.h>
 
@@ -295,7 +296,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;
-       double* lens = (double*)MALLOC(sizeof(double) * edge->npoints);
+       std::unique_ptr<double[]> lens(new double[edge->npoints]);
 
        for (j = 0; j < edge->npoints - 1; j++){
                len = 0;
@@ -317,7 +318,6 @@ static void genBundleColors(pedge edge, std::ostream &os, double maxwgt) {
                }
        }
        os << std::dec << std::setw(0); // reset stream characteristics
-       free (lens);
 }
 
 static void