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/06/21 20:44:50 UTC

svn commit: r549584 - /incubator/stdcxx/trunk/src/exception.cpp

Author: faridz
Date: Thu Jun 21 11:44:49 2007
New Revision: 549584

URL: http://svn.apache.org/viewvc?view=rev&rev=549584
Log:
2007-06-21 Farid Zaripov <Fa...@epam.com>

	STDCXX-293
	* exception.cpp (__rw_free_what_buf): New function to free buffer, allocated by __rw_vfmtwhat().
	Used __rw_free_what_buf() instead of delete[].

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

Modified: incubator/stdcxx/trunk/src/exception.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/src/exception.cpp?view=diff&rev=549584&r1=549583&r2=549584
==============================================================================
--- incubator/stdcxx/trunk/src/exception.cpp (original)
+++ incubator/stdcxx/trunk/src/exception.cpp Thu Jun 21 11:44:49 2007
@@ -438,6 +438,13 @@
 static _RWSTD_THREAD int
 __rw_what_refcnt;
 
+inline void __rw_free_what_buf (char* buf)
+{
+    if (__rw_what_buf == buf)
+        _RWSTD_THREAD_PREDECREMENT (__rw_what_refcnt, false);
+    else
+        delete[] buf;
+}
 
 // allocate a char array and format it sprintf-style
 // caller responsible for calling delete[] on returned pointer
@@ -547,14 +554,8 @@
         if (bufsize)
             return 0;
 
-        if (buf == __rw_what_buf) {
-            _RWSTD_THREAD_PREDECREMENT (__rw_what_refcnt, false);
-        }
-        else {
-            delete[] buf;
-        }
+        __rw_free_what_buf (buf);
         buf = new char [size];
-
     }
 
     return buf;
@@ -741,13 +742,13 @@
             _STD::runtime_error ()._C_assign (what, 0);
     }
 
-    delete[] what;
+    __rw_free_what_buf (what);
 
 #else   // if defined (_RWSTD_NO_EXCEPTIONS)
 
     if (what) {
         fprintf (stderr,"Exception: %s.\n", what);
-        delete[] what;
+        __rw_free_what_buf (what);
     }
     else {
         const char *__str;
@@ -828,7 +829,7 @@
         __rw_throw_proc (id, what);
 
         // if throw_proc returns, delete allocated what string
-        delete[] what;
+        __rw_free_what_buf (what);
     }
 }
 
@@ -867,12 +868,7 @@
 // outlined to avoid functional compatibility issues
 /* virtual */ __rw_exception::~__rw_exception () _THROWS (())
 {
-    if (_C_what == __rw_what_buf) {
-        _RWSTD_THREAD_PREDECREMENT (__rw_what_refcnt, false);
-    }
-    else {
-        delete[] _C_what;
-    }
+    __rw_free_what_buf (_C_what);
 
 #ifdef _C_dummy_what
     // zero out dummy member of the base exception class
@@ -931,7 +927,7 @@
             }
         }
 
-        delete[] _C_what;
+        __rw_free_what_buf (_C_what);
         _C_what = tmp;
     }
     return *this;