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/08/09 16:21:44 UTC

svn commit: r564213 - /incubator/stdcxx/trunk/include/sstream.cc

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 <Fa...@epam.com>

	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 ());
     }



RE: svn commit: r564213 - /incubator/stdcxx/trunk/include/sstream.cc

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Tuesday, August 14, 2007 7:42 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r564213 - 
> /incubator/stdcxx/trunk/include/sstream.cc
> 
> This isn't the reason for STDCXX-515, is it?

  No. The STDCXX-514 and STDCXX-515 is the different independent bugs.

Farid.

Re: svn commit: r564213 - /incubator/stdcxx/trunk/include/sstream.cc

Posted by Martin Sebor <se...@roguewave.com>.
This isn't the reason for STDCXX-515, is it?

Martin

faridz@apache.org 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 <Fa...@epam.com>
> 
> 	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 ());
>      }
> 
>