[mapguide-commits] r9209 - sandbox/jng/geoprocessing/Common/Geometry

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sat Jun 10 09:16:13 PDT 2017


Author: jng
Date: 2017-06-10 09:16:13 -0700 (Sat, 10 Jun 2017)
New Revision: 9209

Modified:
   sandbox/jng/geoprocessing/Common/Geometry/GeometrySimplifier.cpp
Log:
Plug a memory leak in MgGeometrySimplifier

Modified: sandbox/jng/geoprocessing/Common/Geometry/GeometrySimplifier.cpp
===================================================================
--- sandbox/jng/geoprocessing/Common/Geometry/GeometrySimplifier.cpp	2017-06-10 16:15:32 UTC (rev 9208)
+++ sandbox/jng/geoprocessing/Common/Geometry/GeometrySimplifier.cpp	2017-06-10 16:16:13 UTC (rev 9209)
@@ -33,7 +33,7 @@
 MgGeometry* MgGeometrySimplifier::Simplify(MgGeometry* geom, double tolerance, INT32 algorithm)
 {
     Ptr<MgGeometry> simplified;
-    Geometry* gInput = NULL;
+    std::auto_ptr<Geometry> gInput;
     std::auto_ptr<Geometry> gOutput;
     MG_GEOMETRY_TRY()
 
@@ -50,15 +50,15 @@
     WKTReader r(&gf);
     WKTWriter w;
 
-    gInput = r.read(MgUtil::WideCharToMultiByte(inputWKt));
+    gInput.reset(r.read(MgUtil::WideCharToMultiByte(inputWKt)));
 
     switch (algorithm)
     {
     case MgGeometrySimplificationAlgorithmType::DouglasPeucker:
-        gOutput = geos::simplify::DouglasPeuckerSimplifier::simplify(gInput, tolerance);
+        gOutput = geos::simplify::DouglasPeuckerSimplifier::simplify(gInput.get(), tolerance);
         break;
     case MgGeometrySimplificationAlgorithmType::TopologyPreserving:
-        gOutput = geos::simplify::TopologyPreservingSimplifier::simplify(gInput, tolerance);
+        gOutput = geos::simplify::TopologyPreservingSimplifier::simplify(gInput.get(), tolerance);
         break;
     }
 
@@ -72,6 +72,7 @@
     }
     
     MG_GEOMETRY_CATCH_AND_THROW(L"MgGeometrySimplifier.Simplify")
+
     return simplified.Detach();
 }
 



More information about the mapguide-commits mailing list