From ea51a12f0c076a9f5c47d0866fd01d7731214aa1 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 17 Feb 2021 21:15:54 -0800 Subject: [PATCH] remove manual memory management of rectangle array This unifies some Windows and non-Windows code, removes some unwise VLAs, and removes the need to manually deallocate this array, making the code less error prone. We could go further with removing manual allocations, but for now this is a minimal net improvement. --- lib/vpsc/csolve_VPSC.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/vpsc/csolve_VPSC.cpp b/lib/vpsc/csolve_VPSC.cpp index 482c16ce0..72b5c3913 100644 --- a/lib/vpsc/csolve_VPSC.cpp +++ b/lib/vpsc/csolve_VPSC.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include Variable* newVariable(int id, double desiredPos, double weight) { return new Variable(id,desiredPos,weight); @@ -38,39 +39,25 @@ VPSC* newIncVPSC(int n, Variable* vs[], int m, Constraint* cs[]) { } int genXConstraints(int n, boxf* bb, Variable** vs, Constraint*** cs,int transitiveClosure) { -#ifdef _WIN32 - Rectangle** rs = new Rectangle* [n]; -#else - Rectangle* rs[n]; -#endif + std::vector rs(n); for(int i=0;i rs(n); for(int i=0;i