From: Matthew Fernandez Date: Sat, 21 Nov 2020 02:04:10 +0000 (-0800) Subject: remove a manual allocation X-Git-Tag: 2.46.1~29^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d430fddf915cc2aff2281a84dfd89326ebce12e1;p=graphviz remove a manual allocation --- diff --git a/lib/vpsc/remove_rectangle_overlap.cpp b/lib/vpsc/remove_rectangle_overlap.cpp index 62910fd3d..f62dbb956 100644 --- a/lib/vpsc/remove_rectangle_overlap.cpp +++ b/lib/vpsc/remove_rectangle_overlap.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using std::ios; using std::ofstream; @@ -57,10 +58,11 @@ void removeRectangleOverlap(int n, Rectangle *rs[], double xBorder, double yBord vs[i]=new Variable(i,0,1); } Constraint **cs; - double *oldX = new double[n]; + std::vector oldX; + oldX.reserve(n); int m=generateXConstraints(n,rs,vs,cs,true); for(int i=0;idesiredPosition; + oldX.push_back(vs[i]->desiredPosition); } VPSC vpsc_x(n,vs,m,cs); if (RECTANGLE_OVERLAP_LOGGING) { @@ -89,7 +91,6 @@ void removeRectangleOverlap(int n, Rectangle *rs[], double xBorder, double yBord rs[i]->moveCentreY(vs[i]->position()); rs[i]->moveCentreX(oldX[i]); } - delete [] oldX; for(int i = 0; i < m; ++i) { delete cs[i]; }