[geos-commits] [SCM] GEOS branch master updated. 18ced84d7cedda697170a346873c2c359454447b

git at osgeo.org git at osgeo.org
Wed Jan 27 16:31:15 PST 2021


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  18ced84d7cedda697170a346873c2c359454447b (commit)
      from  7b70ce9797df1fa0d9c6a92aa7e5f86494116946 (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 18ced84d7cedda697170a346873c2c359454447b
Author: Daniel Baston <dbaston at gmail.com>
Date:   Wed Jan 27 19:30:21 2021 -0500

    Clear compiler warning in GEOSGeom_createPolygon_r
    
    Rewrite to use managed GeometryFactory methods.

diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index 27ed55a..052c60f 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -2400,35 +2400,31 @@ extern "C" {
     {
         using geos::geom::LinearRing;
 
-        // FIXME: holes must be non-nullptr or may be nullptr?
-        //assert(0 != holes);
-
         return execute(extHandle, [&]() {
+            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            const GeometryFactory* gf = handle->geomFactory;
 
-            std::vector<LinearRing*> tmpholes(nholes);
+            // Validate input before taking ownership
             for (size_t i = 0; i < nholes; i++) {
-                LinearRing* lr = dynamic_cast<LinearRing*>(holes[i]);
-                if (! lr) {
+                if (!dynamic_cast<LinearRing*>(holes[i])) {
                     throw IllegalArgumentException("Hole is not a LinearRing");
                 }
-                tmpholes[i] = lr;
             }
-            LinearRing* nshell = dynamic_cast<LinearRing*>(shell);
-            if(! nshell) {
+            if (!dynamic_cast<LinearRing*>(shell)) {
                 throw IllegalArgumentException("Shell is not a LinearRing");
             }
-            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-            const GeometryFactory* gf = handle->geomFactory;
 
-            /* Create unique_ptr version for constructor */
-            std::vector<std::unique_ptr<LinearRing>> vholes;
-            vholes.reserve(nholes);
-            for (LinearRing* lr: tmpholes) {
-                vholes.emplace_back(lr);
+            std::unique_ptr<LinearRing> tmpshell(static_cast<LinearRing*>(shell));
+            if (nholes) {
+                std::vector<std::unique_ptr<LinearRing>> tmpholes(nholes);
+                for (size_t i = 0; i < nholes; i++) {
+                    tmpholes[i].reset(static_cast<LinearRing*>(holes[i]));
+                }
+
+                return gf->createPolygon(std::move(tmpshell), std::move(tmpholes)).release();
             }
-            std::unique_ptr<LinearRing> shell(nshell);
 
-            return gf->createPolygon(std::move(shell), std::move(vholes)).release();
+            return gf->createPolygon(std::move(tmpshell)).release();
         });
     }
 

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

Summary of changes:
 capi/geos_ts_c.cpp | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list