This isn't the reason for STDCXX-515, is it?
Martin
[EMAIL PROTECTED] wrote:
Author: faridz
Date: Thu Aug 9 07:21:44 2007
New Revision: 564213
URL: http://svn.apache.org/viewvc?view=rev&rev=564213
Log:
2007-08-09 Farid Zaripov <[EMAIL PROTECTED]>
STDCXX-514
* sstream.cc (str): Take ownership of the allocated buffer a bit
later to avoid deallocation of the external buffer.
Modified:
incubator/stdcxx/trunk/include/sstream.cc
Modified: incubator/stdcxx/trunk/include/sstream.cc
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/sstream.cc?view=diff&rev=564213&r1=564212&r2=564213
==============================================================================
--- incubator/stdcxx/trunk/include/sstream.cc (original)
+++ incubator/stdcxx/trunk/include/sstream.cc Thu Aug 9 07:21:44 2007
@@ -111,9 +111,6 @@
}
__buf = __alloc.allocate (__bufsize);
-
- // take ownsership of the allocated buffer
- this->_C_own_buf (true);
}
else if (0 < __bufsize) {
// requested capacity is the same or less than the current one
@@ -139,6 +136,9 @@
if (this->_C_buffer && this->_C_own_buf ())
__alloc.deallocate (this->_C_buffer, this->_C_bufsize);
+ // take ownership of the allocated buffer
+ this->_C_own_buf (true);
+
this->_C_buffer = __buf;
this->_C_bufsize = __bufsize;
}
@@ -185,20 +185,9 @@
const _RWSTD_SIZE_T __bufsize =
__n + (this->pptr () - this->pbase ());
- _RWSTD_PTRDIFF_T __off = -1;
-
- if (this->pbase () <= __s && this->pptr () > __s) {
- // __s is part of buffer
- _RWSTD_ASSERT (this->epptr () >= __s + __n);
- __off = this->pbase () - __s;
- }
-
// grow the buffer if necessary to accommodate the whole
// string plus the contents of the buffer up to pptr()
str (this->_C_buffer, __bufsize);
-
- if (0 <= __off)
- __s = this->pbase () + __off;
_RWSTD_ASSERT (__n <= this->epptr () - this->pptr ());
}