stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r590101 - /incubator/stdcxx/trunk/src/time_put.cpp
Date Tue, 30 Oct 2007 14:54:12 GMT
Author: faridz
Date: Tue Oct 30 07:54:10 2007
New Revision: 590101

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

	Merged r587215 from branches/4.2.x with a fix for STDCXX-578
	* time_put.cpp (__rw_get_timepunct): changed to use operator
	new/delete for memory allocation to avoid new/delete mismatch with
	facet destructor.

Modified:
    incubator/stdcxx/trunk/src/time_put.cpp

Modified: incubator/stdcxx/trunk/src/time_put.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/src/time_put.cpp?rev=590101&r1=590100&r2=590101&view=diff
==============================================================================
--- incubator/stdcxx/trunk/src/time_put.cpp (original)
+++ incubator/stdcxx/trunk/src/time_put.cpp Tue Oct 30 07:54:10 2007
@@ -451,7 +451,11 @@
 
     _RWSTD_SIZE_T bufsize = 2048;
 
-    char *pbuf = new char [sizeof (__rw_time_t) + bufsize];
+    const size_t newsize = bufsize + sizeof (__rw_time_t);
+ 
+    // allocate memory using operator new to avoid mismatch with
+    // facet destructor
+    char *pbuf = _RWSTD_STATIC_CAST (char*, ::operator new (newsize));
 
     __rw_time_t *pun = _RWSTD_REINTERPRET_CAST (__rw_time_t*, pbuf);
 
@@ -603,10 +607,15 @@
 
         if (off + estsize >= bufsize) {
             // reallocate
-            char* const tmp = new char [sizeof *pun + bufsize * 2 + estsize];
+            const size_t tmpsize = sizeof *pun + bufsize * 2 + estsize;
+
+            // reallocate, again using operator new to avoid mismatch
+            // with facet destructor
+            char* const tmp = 
+                _RWSTD_STATIC_CAST(char* const, ::operator new (tmpsize));
             memcpy (tmp, pun, sizeof *pun + off);
 
-            delete[] _RWSTD_REINTERPRET_CAST (char*, pun);
+            ::operator delete (_RWSTD_REINTERPRET_CAST (char*, pun));
 
             pun      = _RWSTD_REINTERPRET_CAST (__rw_time_t*, tmp);
             pmem     = _RWSTD_REINTERPRET_CAST (_RWSTD_UINT32_T*, pun);



Mime
View raw message