[geos-commits] r3598 - trunk/src/noding/snapround
svn_geos at osgeo.org
svn_geos at osgeo.org
Thu Apr 5 10:53:53 EDT 2012
Author: strk
Date: 2012-04-05 07:53:53 -0700 (Thu, 05 Apr 2012)
New Revision: 3598
Modified:
trunk/src/noding/snapround/SimpleSnapRounder.cpp
Log:
Fix SimpleSnapRounder::getNodedSubstrings, fix leak on exception
Modified: trunk/src/noding/snapround/SimpleSnapRounder.cpp
===================================================================
--- trunk/src/noding/snapround/SimpleSnapRounder.cpp 2012-04-05 14:37:13 UTC (rev 3597)
+++ trunk/src/noding/snapround/SimpleSnapRounder.cpp 2012-04-05 14:53:53 UTC (rev 3598)
@@ -54,7 +54,9 @@
std::vector<SegmentString*>*
SimpleSnapRounder::getNodedSubstrings() const
{
- return nodedSegStrings;
+ std::vector<SegmentString*> *ret = new std::vector<SegmentString*>();
+ NodedSegmentString::getNodedSubstrings(nodedSegStrings->begin(), nodedSegStrings->end(), ret);
+ return ret;
}
/*public*/
@@ -76,17 +78,36 @@
SimpleSnapRounder::checkCorrectness(
SegmentString::NonConstVect& inputSegmentStrings)
{
- auto_ptr<SegmentString::NonConstVect> resultSegStrings(
- NodedSegmentString::getNodedSubstrings(inputSegmentStrings)
- );
+ SegmentString::NonConstVect resultSegStrings;
+ NodedSegmentString::getNodedSubstrings(
+ inputSegmentStrings.begin(), inputSegmentStrings.end(), &resultSegStrings
+ );
- NodingValidator nv(*(resultSegStrings.get()));
- try {
- nv.checkValid();
- } catch (const std::exception &ex) {
- std::cerr << ex.what() << std::endl;
- throw;
- }
+ NodingValidator nv(resultSegStrings);
+
+ try {
+ nv.checkValid();
+ }
+
+ catch (const std::exception &ex) {
+
+ for ( SegmentString::NonConstVect::iterator i=resultSegStrings.begin(),
+ e=resultSegStrings.end();
+ i!=e; ++i )
+ {
+ delete *i;
+ }
+
+ std::cerr << ex.what() << std::endl;
+ throw;
+ }
+
+ for ( SegmentString::NonConstVect::iterator i=resultSegStrings.begin(),
+ e=resultSegStrings.end();
+ i!=e; ++i )
+ {
+ delete *i;
+ }
}
More information about the geos-commits
mailing list