stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r587215 - /incubator/stdcxx/branches/4.2.x/src/time_put.cpp
Date Mon, 22 Oct 2007 19:27:56 GMT
Author: faridz
Date: Mon Oct 22 12:27:55 2007
New Revision: 587215

URL: http://svn.apache.org/viewvc?rev=587215&view=rev
Log:
2007-10-22 Travis Vitek <vitek@roguewave.com>

	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/branches/4.2.x/src/time_put.cpp

Modified: incubator/stdcxx/branches/4.2.x/src/time_put.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/src/time_put.cpp?rev=587215&r1=587214&r2=587215&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/src/time_put.cpp (original)
+++ incubator/stdcxx/branches/4.2.x/src/time_put.cpp Mon Oct 22 12:27:55 2007
@@ -450,7 +450,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);
 
@@ -602,10 +606,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