[prev in list] [next in list] [prev in thread] [next in thread]
List: geos-commits
Subject: [geos-commits] r2700 - in trunk/source: headers/geos/linearref
From: svn_geos () osgeo ! org
Date: 2009-10-23 13:04:19
Message-ID: 20091023130419.4F1C4E009A4 () lists ! osgeo ! org
[Download RAW message or body]
Author: strk
Date: 2009-10-23 09:04:18 -0400 (Fri, 23 Oct 2009)
New Revision: 2700
Modified:
trunk/source/headers/geos/linearref/LinearLocation.h
trunk/source/linearref/LinearLocation.cpp
Log:
Have LinearLocation::getSegment return by auto_ptr to encode ownership transfer. \
Fixes leak reported in #296.
Modified: trunk/source/headers/geos/linearref/LinearLocation.h
===================================================================
--- trunk/source/headers/geos/linearref/LinearLocation.h 2009-10-23 12:58:48 UTC (rev \
2699)
+++ trunk/source/headers/geos/linearref/LinearLocation.h 2009-10-23 13:04:18 UTC (rev \
2700) @@ -22,6 +22,7 @@
#define GEOS_LINEARREF_LINEARLOCATION_H
#include <string>
+#include <memory> // for std::auto_ptr
#include <geos/geom/Coordinate.h>
#include <geos/geom/Geometry.h>
@@ -167,7 +168,7 @@
* @param linearGeom a linear geometry
* @return the <tt>LineSegment</tt> containing the location
*/
- geom::LineSegment *getSegment(const geom::Geometry* linearGeom) const;
+ std::auto_ptr<geom::LineSegment> getSegment(const geom::Geometry* linearGeom) \
const;
/**
* Tests whether this location refers to a valid
Modified: trunk/source/linearref/LinearLocation.cpp
===================================================================
--- trunk/source/linearref/LinearLocation.cpp 2009-10-23 12:58:48 UTC (rev 2699)
+++ trunk/source/linearref/LinearLocation.cpp 2009-10-23 13:04:18 UTC (rev 2700)
@@ -209,7 +209,7 @@
}
/* public */
-LineSegment*
+std::auto_ptr<LineSegment>
LinearLocation::getSegment(const Geometry* linearGeom) const
{
const LineString* lineComp = dynamic_cast<const LineString *> \
(linearGeom->getGeometryN(componentIndex)); @@ -218,10 +218,10 @@
if (segmentIndex >= lineComp->getNumPoints() - 1)
{
Coordinate prev = lineComp->getCoordinateN(lineComp->getNumPoints() - 2);
- return new LineSegment(prev, p0);
+ return std::auto_ptr<LineSegment>(new LineSegment(prev, p0));
}
Coordinate p1 = lineComp->getCoordinateN(segmentIndex + 1);
- return new LineSegment(p0, p1);
+ return std::auto_ptr<LineSegment>(new LineSegment(p0, p1));
}
/* public */
@@ -278,7 +278,7 @@
}
-/* public */
+/* public static */
int
LinearLocation::compareLocationValues(
unsigned int componentIndex0, unsigned int segmentIndex0,
_______________________________________________
geos-commits mailing list
geos-commits@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic