You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2007/10/01 15:56:50 UTC

svn commit: r580959 - /incubator/stdcxx/branches/4.2.0/src/punct.cpp

Author: faridz
Date: Mon Oct  1 06:56:49 2007
New Revision: 580959

URL: http://svn.apache.org/viewvc?rev=580959&view=rev
Log:
2007-10-01  Farid Zaripov  <fa...@epam.com>

	STDCXX-453
	* punct.cpp (__rw_get_moneypunct): After creating __rw_setlocale
	object check if the locale data is initialized by another thread
	to avoid doing unnecessary work and leaking memory.
	(__rw_get_numpunct): Ditto.

Modified:
    incubator/stdcxx/branches/4.2.0/src/punct.cpp

Modified: incubator/stdcxx/branches/4.2.0/src/punct.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/punct.cpp?rev=580959&r1=580958&r2=580959&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.0/src/punct.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/src/punct.cpp Mon Oct  1 06:56:49 2007
@@ -132,6 +132,14 @@
     // set all categories -- need LC_NUMERIC and LC_CTYPE
     const __rw_setlocale clocale (locname, _RWSTD_LC_ALL);
 
+    if (pfacet->_C_data ()) {
+        // check to see if another thread may have set _C_data()
+        // while we were waiting for the lock in __rw_setlocale
+        // ctor above and, if so, call self recursively on the
+        // already initialized `impdata'
+        return __rw_get_numpunct (pfacet, flags);
+    }
+
     // get the lconv data
     const lconv* const pconv = localeconv ();
     if (!pconv)
@@ -307,6 +315,14 @@
     
     // set all categories -- need LC_NUMERIC and LC_CTYPE
     const __rw_setlocale clocale (locname, _RWSTD_LC_ALL);
+
+    if (pfacet->_C_data ()) {
+        // check to see if another thread may have set _C_data()
+        // while we were waiting for the lock in __rw_setlocale
+        // ctor above and, if so, call self recursively on the
+        // already initialized `impdata'
+        return __rw_get_moneypunct (pfacet, flags);
+    }
 
     // get the lconv data
     const lconv* const pconv = localeconv ();