[geos-commits] r2176 - trunk/capi

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Aug 28 20:30:47 EDT 2008


Author: mloskot
Date: 2008-08-28 20:30:47 -0400 (Thu, 28 Aug 2008)
New Revision: 2176

Modified:
   trunk/capi/geos_c.cpp
Log:
Fixed execution paths and removed redundant return expr in some C API calls.

Modified: trunk/capi/geos_c.cpp
===================================================================
--- trunk/capi/geos_c.cpp	2008-08-29 00:29:58 UTC (rev 2175)
+++ trunk/capi/geos_c.cpp	2008-08-29 00:30:47 UTC (rev 2176)
@@ -2035,7 +2035,7 @@
 	try
 	{
 		std::string s = writer->write(geom);
-		char *result;
+		char *result = NULL;
 		result = (char*) std::malloc( s.length() + 1);
 		std::strcpy(result, s.c_str() );
 		return result;
@@ -2043,14 +2043,13 @@
 	catch (const std::exception &e)
 	{
 		ERROR_MESSAGE("%s", e.what());
-		return NULL;
 	}
-
 	catch (...)
 	{
 		ERROR_MESSAGE("Unknown exception thrown");
-		return NULL;
 	}
+    
+    return NULL;
 }
 
 /* WKB Reader */
@@ -2065,14 +2064,13 @@
 	catch (const std::exception &e)
 	{
 		ERROR_MESSAGE("%s", e.what());
-		return NULL;
 	}
-
 	catch (...)
 	{
 		ERROR_MESSAGE("Unknown exception thrown");
-		return NULL;
 	}
+    
+    return NULL;
 }
 
 void
@@ -2110,14 +2108,13 @@
 	catch (const std::exception &e)
 	{
 		ERROR_MESSAGE("%s", e.what());
-		return NULL;
 	}
-
 	catch (...)
 	{
 		ERROR_MESSAGE("Unknown exception thrown");
-		return NULL;
 	}
+    
+    return NULL;
 }
 
 Geometry*
@@ -2136,14 +2133,13 @@
 	catch (const std::exception &e)
 	{
 		ERROR_MESSAGE("%s", e.what());
-		return NULL;
 	}
-
 	catch (...)
 	{
 		ERROR_MESSAGE("Unknown exception thrown");
-		return NULL;
 	}
+    
+    return NULL;
 }
 
 /* WKB Writer */
@@ -2158,14 +2154,13 @@
 	catch (const std::exception &e)
 	{
 		ERROR_MESSAGE("%s", e.what());
-		return NULL;
 	}
-
 	catch (...)
 	{
 		ERROR_MESSAGE("Unknown exception thrown");
-		return NULL;
 	}
+    
+    return NULL;
 }
 
 void
@@ -2198,7 +2193,7 @@
 		std::string wkbstring = s.str();
 		size_t len = wkbstring.length();
 
-		unsigned char *result;
+		unsigned char *result = NULL;
 		result = (unsigned char*) std::malloc(len);
         std::memcpy(result, wkbstring.c_str(), len);
 		*size = len;
@@ -2207,14 +2202,12 @@
 	catch (const std::exception &e)
 	{
 		ERROR_MESSAGE("%s", e.what());
-		return NULL;
 	}
-
 	catch (...)
 	{
 		ERROR_MESSAGE("Unknown exception thrown");
-		return NULL;
 	}
+    return NULL;
 }
 
 /* The owner owns the result */
@@ -2226,9 +2219,9 @@
 		std::ostringstream s(std::ios_base::binary);
 		writer->writeHEX(*geom, s);
 		std::string wkbstring = s.str();
-		size_t len = wkbstring.length();
+		const size_t len = wkbstring.length();
 
-		unsigned char *result;
+		unsigned char *result = NULL;
 		result = (unsigned char*) std::malloc(len);
         std::memcpy(result, wkbstring.c_str(), len);
 		*size = len;
@@ -2237,14 +2230,13 @@
 	catch (const std::exception &e)
 	{
 		ERROR_MESSAGE("%s", e.what());
-		return NULL;
 	}
 
 	catch (...)
 	{
 		ERROR_MESSAGE("Unknown exception thrown");
-		return NULL;
 	}
+    return NULL;
 }
 
 int
@@ -2258,8 +2250,8 @@
 	catch (...)
 	{
 		ERROR_MESSAGE("Unknown exception thrown");
-		return NULL;
 	}
+    return 0;
 }
 
 void
@@ -2287,8 +2279,8 @@
 	catch (...)
 	{
 		ERROR_MESSAGE("Unknown exception thrown");
-		return NULL;
 	}
+    return 0;
 }
 
 void
@@ -2342,11 +2334,11 @@
 const geos::geom::prep::PreparedGeometry*
 GEOSPrepare(const Geometry *g)
 {
-	try
+    const geos::geom::prep::PreparedGeometry* prep = NULL;
+	
+    try
 	{
-		const geos::geom::prep::PreparedGeometry* prep;
-		prep = geos::geom::prep::PreparedGeometryFactory::prepare( g);
-		return prep;
+		prep = geos::geom::prep::PreparedGeometryFactory::prepare(g);
 	}
 	catch (const std::exception &e)
 	{
@@ -2356,6 +2348,8 @@
 	{
 		ERROR_MESSAGE("Unknown exception thrown");
 	}
+	
+    return prep;
 }
 
 void



More information about the geos-commits mailing list