[geos-commits] r2658 - trunk/source/operation/buffer

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Oct 5 15:30:00 EDT 2009


Author: strk
Date: 2009-10-05 15:29:45 -0400 (Mon, 05 Oct 2009)
New Revision: 2658

Modified:
   trunk/source/operation/buffer/BufferBuilder.cpp
Log:
release memory earlier, and closer to allocation

Modified: trunk/source/operation/buffer/BufferBuilder.cpp
===================================================================
--- trunk/source/operation/buffer/BufferBuilder.cpp	2009-10-05 19:04:56 UTC (rev 2657)
+++ trunk/source/operation/buffer/BufferBuilder.cpp	2009-10-05 19:29:45 UTC (rev 2658)
@@ -182,20 +182,21 @@
    {
       SegmentString* ss = ( *nodedEdges )[i];
 
-      Geometry* tmp = geomFact->createLineString( ss->getCoordinates()->clone() );
+      Geometry* tmp = geomFact->createLineString(
+                        ss->getCoordinates()->clone()
+                      );
       singleSidedNodedEdges->push_back( tmp );
    }
 
-   if ( nodedEdges != &curveList )
-   {
-      delete nodedEdges;
-   }
+   if ( nodedEdges != &curveList ) delete nodedEdges;
 
-   for (size_t i=0; i<lineList.size(); ++i)
-   {
-      delete lineList[i];
-   }
+   for (size_t i=0, n=curveList.size(); i<n; ++i) delete curveList[i];
+   curveList.clear();
 
+   for (size_t i=0, n=lineList.size(); i<n; ++i) delete lineList[i];
+   lineList.clear();
+
+
    Geometry* singleSided = geomFact->createMultiLineString(
       singleSidedNodedEdges );
 
@@ -313,11 +314,6 @@
    geomFact->destroyGeometry( singleSided );
    geomFact->destroyGeometry( intersectedLines );
 
-   for (size_t i=0; i<curveList.size(); ++i)
-   {
-      delete curveList[i];
-   }
-
    if ( mergedLinesGeom->size() > 1 ) return geomFact->createMultiLineString( mergedLinesGeom );
    else
    {



More information about the geos-commits mailing list