← Back to team overview

kicad-developers team mailing list archive

[PATCH 2/6] Avoid nonstandard variable length array

 

---
 common/geometry/shape_poly_set.cpp                      | 4 ++--
 qa/polygon_triangulation/test_polygon_triangulation.cpp | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/geometry/shape_poly_set.cpp b/common/geometry/shape_poly_set.cpp
index 7c0d2f38f..ff2ad8742 100644
--- a/common/geometry/shape_poly_set.cpp
+++ b/common/geometry/shape_poly_set.cpp
@@ -942,7 +942,7 @@ void SHAPE_POLY_SET::unfractureSingle( SHAPE_POLY_SET::POLYGON& aPoly )
     auto lc = aPoly[0];
     lc.Simplify();
 
-    EDGE_LIST_ENTRY edgeList[ lc.SegmentCount() ];
+    auto edgeList = std::make_unique<EDGE_LIST_ENTRY []>( lc.SegmentCount() );
 
     for( int i = 0; i < lc.SegmentCount(); i++ )
     {
@@ -1004,7 +1004,7 @@ void SHAPE_POLY_SET::unfractureSingle( SHAPE_POLY_SET::POLYGON& aPoly )
             queue.insert( &edgeList[i] );
     }
 
-    EDGE_LIST_ENTRY* edgeBuf[ lc.SegmentCount() ];
+    auto edgeBuf = std::make_unique<EDGE_LIST_ENTRY* []>( lc.SegmentCount() );
 
     int n = 0;
     int outline = -1;
diff --git a/qa/polygon_triangulation/test_polygon_triangulation.cpp b/qa/polygon_triangulation/test_polygon_triangulation.cpp
index c23af207d..432a323a1 100644
--- a/qa/polygon_triangulation/test_polygon_triangulation.cpp
+++ b/qa/polygon_triangulation/test_polygon_triangulation.cpp
@@ -33,7 +33,7 @@
 #include <profile.h>
 
 #include <unordered_set>
-
+#include <utility>
 
 
 void unfracture( SHAPE_POLY_SET::POLYGON* aPoly, SHAPE_POLY_SET::POLYGON* aResult )
@@ -88,7 +88,7 @@ void unfracture( SHAPE_POLY_SET::POLYGON* aPoly, SHAPE_POLY_SET::POLYGON* aResul
     auto lc = (*aPoly)[0];
     lc.Simplify();
 
-    EDGE_LIST_ENTRY edgeList[ lc.SegmentCount() ];
+    auto edgeList = std::make_unique<EDGE_LIST_ENTRY []>( lc.SegmentCount() );
 
     for(int i = 0; i < lc.SegmentCount(); i++)
     {
@@ -149,7 +149,7 @@ void unfracture( SHAPE_POLY_SET::POLYGON* aPoly, SHAPE_POLY_SET::POLYGON* aResul
         //printf("Skip %d\n", i);
     }
 
-    EDGE_LIST_ENTRY* edgeBuf[ lc.SegmentCount() ];
+    auto edgeBuf = std::make_unique<EDGE_LIST_ENTRY* []>( lc.SegmentCount() );
 
     int n = 0;
     int outline = -1;

References