[geos-commits] [SCM] GEOS branch master updated. 0d1aaa6e8f1732d57b4f810d2bddd3de9f150f47

git at osgeo.org git at osgeo.org
Mon Apr 15 08:15:27 PDT 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, master has been updated
       via  0d1aaa6e8f1732d57b4f810d2bddd3de9f150f47 (commit)
      from  d352f3c7cb208a1fbed09ec4ed54496d0d3c4a04 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0d1aaa6e8f1732d57b4f810d2bddd3de9f150f47
Author: Daniel Baston <dbaston at gmail.com>
Date:   Mon Apr 15 11:15:13 2019 -0400

    Fix memory leaks in GeometryCollection unit test

diff --git a/tests/unit/geom/GeometryCollectionTest.cpp b/tests/unit/geom/GeometryCollectionTest.cpp
index cda9259..b2cf106 100644
--- a/tests/unit/geom/GeometryCollectionTest.cpp
+++ b/tests/unit/geom/GeometryCollectionTest.cpp
@@ -4,6 +4,8 @@
 #include <tut/tut.hpp>
 #include <utility.h>
 
+#include <memory>
+
 
 namespace tut {
 //
@@ -38,15 +40,17 @@ template<>
 void object::test<1>
 ()
 {
-    GeometryPtr empty_point = factory_->createPoint();
+    using geos::geom::Geometry;
+
+    std::unique_ptr<Geometry> empty_point(factory_->createPoint());
     ensure(empty_point != nullptr);
 
     geos::geom::Coordinate coord(1, 2);
-    GeometryPtr point = factory_->createPoint(coord);
+    std::unique_ptr<Geometry> point(factory_->createPoint(coord));
     ensure(point != nullptr);
 
-    std::vector<GeometryPtr> geoms{empty_point, point};
-    GeometryColPtr col = factory_->createGeometryCollection(geoms);
+    std::vector<Geometry*> geoms{empty_point.get(), point.get()};
+    std::unique_ptr<Geometry> col(factory_->createGeometryCollection(geoms));
     ensure(col != nullptr);
 
     ensure(col->getCoordinate() != nullptr);
@@ -60,23 +64,21 @@ template<>
 void object::test<2>
 ()
 {
+    using geos::geom::Geometry;
+
     geos::geom::PrecisionModel pm;
     auto gf = GeometryFactory::create(&pm, 1);
-    auto g = gf->createEmptyGeometry();
+    std::unique_ptr<Geometry> g(gf->createEmptyGeometry());
 
     g->setSRID(0);
-    std::vector<decltype(g)> v = {g};
-    auto geom_col = gf->createGeometryCollection(v);
+    std::vector<Geometry*> v = {g.get()};
+    std::unique_ptr<Geometry> geom_col(gf->createGeometryCollection(v));
     ensure_equals(geom_col->getGeometryN(0)->getSRID(), 1);
 
     geom_col->setSRID(2);
     ensure_equals(geom_col->getGeometryN(0)->getSRID(), 2);
 
-    auto clone = geom_col->clone();
+    std::unique_ptr<Geometry> clone(geom_col->clone());
     ensure_equals(clone->getGeometryN(0)->getSRID(), 2);
-
-    // FREE MEMORY
-    gf->destroyGeometry(geom_col);
-    gf->destroyGeometry(clone);
 }
 } // namespace tut

-----------------------------------------------------------------------

Summary of changes:
 tests/unit/geom/GeometryCollectionTest.cpp | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list