summaryrefslogtreecommitdiff
path: root/libstdc++-v3/src/strstream.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/src/strstream.cc')
-rw-r--r--libstdc++-v3/src/strstream.cc33
1 files changed, 13 insertions, 20 deletions
diff --git a/libstdc++-v3/src/strstream.cc b/libstdc++-v3/src/strstream.cc
index 7252afde323..0576472ddbe 100644
--- a/libstdc++-v3/src/strstream.cc
+++ b/libstdc++-v3/src/strstream.cc
@@ -60,12 +60,13 @@ namespace std
: _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true),
_M_frozen(false), _M_constant(false)
{
- _M_buf_size = _M_buf_size_opt = max(initial_capacity, streamsize(16));
- _M_buf = _M_alloc(_M_buf_size);
- if (_M_buf)
+ streamsize n = max(initial_capacity, streamsize(16));
+
+ char* buf = _M_alloc(n);
+ if (buf)
{
- setp(_M_buf, _M_buf + _M_buf_size);
- setg(_M_buf, _M_buf, _M_buf);
+ setp(buf, buf + n);
+ setg(buf, buf, buf);
}
}
@@ -73,12 +74,13 @@ namespace std
: _Base(), _M_alloc_fun(alloc_f), _M_free_fun(free_f), _M_dynamic(true),
_M_frozen(false), _M_constant(false)
{
- _M_buf_size = _M_buf_size_opt = 16;
- _M_buf = _M_alloc(_M_buf_size);
- if (_M_buf)
+ streamsize n = 16;
+
+ char* buf = _M_alloc(n);
+ if (buf)
{
- setp(_M_buf, _M_buf + _M_buf_size);
- setg(_M_buf, _M_buf, _M_buf);
+ setp(buf, buf + n);
+ setg(buf, buf, buf);
}
}
@@ -116,14 +118,7 @@ namespace std
strstreambuf::~strstreambuf()
{
if (_M_dynamic && !_M_frozen)
- {
- char* p = this->eback();
- _M_free(p);
- if (p == _M_buf)
- _M_buf = 0;
- }
- if (_M_buf)
- _M_free(_M_buf);
+ _M_free(eback());
}
void
@@ -169,8 +164,6 @@ namespace std
old_get_offset = gptr() - eback();
}
- _M_buf = buf;
- _M_buf_size = _M_buf_size_opt = new_size;
setp(buf, buf + new_size);
pbump(old_size);