[geos-commits] r2180 - in trunk/source: headers/geos/io io

svn_geos at osgeo.org svn_geos at osgeo.org
Sun Aug 31 15:54:27 EDT 2008


Author: mloskot
Date: 2008-08-31 15:54:26 -0400 (Sun, 31 Aug 2008)
New Revision: 2180

Modified:
   trunk/source/headers/geos/io/CLocalizer.h
   trunk/source/io/CLocalizer.cpp
Log:
Removed use of strdup function to fix compilation with GCC 4.3.1 (Ticket #204).

Modified: trunk/source/headers/geos/io/CLocalizer.h
===================================================================
--- trunk/source/headers/geos/io/CLocalizer.h	2008-08-29 18:17:21 UTC (rev 2179)
+++ trunk/source/headers/geos/io/CLocalizer.h	2008-08-31 19:54:26 UTC (rev 2180)
@@ -1,3 +1,4 @@
+#include <string>
 
 namespace geos {
 namespace io {
@@ -5,15 +6,16 @@
 /**
  * \class CLocalizer io.h geos.h
  */
-
 class CLocalizer
 {
-private:
-    char *outer_locale;
+public:
 
-public:
     CLocalizer();
     ~CLocalizer();
+
+private:
+
+    std::string saved_locale;
 };
 
 } // namespace io

Modified: trunk/source/io/CLocalizer.cpp
===================================================================
--- trunk/source/io/CLocalizer.cpp	2008-08-29 18:17:21 UTC (rev 2179)
+++ trunk/source/io/CLocalizer.cpp	2008-08-31 19:54:26 UTC (rev 2180)
@@ -9,26 +9,19 @@
 
 CLocalizer::CLocalizer()
 {
-    outer_locale = strdup(std::setlocale(LC_NUMERIC, NULL));
-    if (std::setlocale(LC_NUMERIC, "C") == NULL)
+    char* p = std::setlocale(LC_NUMERIC, NULL);
+    if (0 != p)
     {
-        if (outer_locale != NULL)
-        {
-            free(outer_locale);
-            outer_locale = NULL;
-        }
+        saved_locale = p;
     }
+    std::setlocale(LC_NUMERIC, "C");
 }
 
 CLocalizer::~CLocalizer()
 {
-    if (outer_locale != NULL)
-    {
-        std::setlocale(LC_NUMERIC, outer_locale);
-        free(outer_locale);
-        outer_locale = NULL;
-    }
+    std::setlocale(LC_NUMERIC, saved_locale.c_str());
 }
 
 } // namespace geos.io
 } // namespace geos
+



More information about the geos-commits mailing list