[geos-commits] r2151 - in trunk: source/headers/geos/geom/prep tests/unit/geom/prep

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Aug 11 19:42:03 EDT 2008


Author: mloskot
Date: 2008-08-11 19:42:01 -0400 (Mon, 11 Aug 2008)
New Revision: 2151

Modified:
   trunk/source/headers/geos/geom/prep/PreparedGeometryFactory.h
   trunk/tests/unit/geom/prep/PreparedGeometryFactoryTest.cpp
Log:
Completed PreparedGeometryFactory class with missing named destructor for PreparedGeometry (Ticket #198)

Modified: trunk/source/headers/geos/geom/prep/PreparedGeometryFactory.h
===================================================================
--- trunk/source/headers/geos/geom/prep/PreparedGeometryFactory.h	2008-08-11 23:35:36 UTC (rev 2150)
+++ trunk/source/headers/geos/geom/prep/PreparedGeometryFactory.h	2008-08-11 23:42:01 UTC (rev 2151)
@@ -47,31 +47,38 @@
  */
 class PreparedGeometryFactory
 {
-private:
-protected:
 public:
+
 	/**
 	* Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}.
 	* 
 	* @param geom the geometry to prepare
 	* @return the prepared geometry
 	*/
-	static const PreparedGeometry * prepare( const geom::Geometry * geom) 
+	static const PreparedGeometry * prepare(const geom::Geometry * geom) 
 	{
 		PreparedGeometryFactory pf;
 		return pf.create(geom); 
 	}
+    
+    /**
+ 	* Destroys {@link PreparedGeometry} allocated with the factory.
+ 	* 
+	* @param geom to be deallocated
+	*/
+    static void destroy(const PreparedGeometry* geom)
+    {
+        delete geom;
+    }
 
-	PreparedGeometryFactory() 
-	{ }
-
 	/**
  	* Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}.
  	* 
 	* @param geom the geometry to prepare
 	* @return the prepared geometry
 	*/
-	const PreparedGeometry* create( const geom::Geometry* geom) const;
+	const PreparedGeometry* create(const geom::Geometry* geom) const;
+
 };
 
 } // namespace geos::geom::prep

Modified: trunk/tests/unit/geom/prep/PreparedGeometryFactoryTest.cpp
===================================================================
--- trunk/tests/unit/geom/prep/PreparedGeometryFactoryTest.cpp	2008-08-11 23:35:36 UTC (rev 2150)
+++ trunk/tests/unit/geom/prep/PreparedGeometryFactoryTest.cpp	2008-08-11 23:42:01 UTC (rev 2151)
@@ -77,7 +77,9 @@
         prep::PreparedGeometry const* pg = prep::PreparedGeometryFactory::prepare(g);
 		ensure( 0 != pg );
 
-        // FIXME: pg leaks here, but we don't know how to destroy
+        // FREE MEMORY
+        prep::PreparedGeometryFactory::destroy(pg);
+        gf.destroyGeometry(g);
 	}
 	
     // Test create with empty POINT
@@ -92,7 +94,10 @@
 		prep::PreparedGeometryFactory pgf;
 		prep::PreparedGeometry const* pg = pgf.create(g);
 		ensure( 0 != pg );
-        // FIXME: pg leaks here, but we don't know how to destroy
+        
+        // FREE MEMORY
+        prep::PreparedGeometryFactory::destroy(pg);
+        gf.destroyGeometry(g);
 	}
 	
 



More information about the geos-commits mailing list