mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-08 08:16:46 +08:00
re PR libstdc++/6594 (strstreambuf leaks 16 bytes - gcc 3.0.x)
2002-05-15 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/6594 * src/strstream.cc (strstreambuf): Fix leak. From-SVN: r53486
This commit is contained in:
parent
bf6f276b01
commit
fb5b4dfdcb
@ -1,3 +1,8 @@
|
||||
2002-05-15 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
PR libstdc++/6594
|
||||
* src/strstream.cc (strstreambuf): Fix leak.
|
||||
|
||||
2002-05-15 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
PR libstdc++/6648
|
||||
|
@ -64,13 +64,13 @@ strstreambuf::strstreambuf(streamsize initial_capacity)
|
||||
_M_alloc_fun(0), _M_free_fun(0),
|
||||
_M_dynamic(true), _M_frozen(false), _M_constant(false)
|
||||
{
|
||||
streamsize n = max(initial_capacity, streamsize(16));
|
||||
|
||||
char* buf = _M_alloc(n);
|
||||
if (buf) {
|
||||
setp(buf, buf + n);
|
||||
setg(buf, buf, buf);
|
||||
}
|
||||
_M_buf_size = _M_buf_size_opt = max(initial_capacity, streamsize(16));
|
||||
_M_buf = _M_alloc(_M_buf_size);
|
||||
if (_M_buf)
|
||||
{
|
||||
setp(_M_buf, _M_buf + _M_buf_size);
|
||||
setg(_M_buf, _M_buf, _M_buf);
|
||||
}
|
||||
}
|
||||
|
||||
strstreambuf::strstreambuf(void* (*alloc_f)(size_t), void (*free_f)(void*))
|
||||
@ -78,12 +78,12 @@ strstreambuf::strstreambuf(void* (*alloc_f)(size_t), void (*free_f)(void*))
|
||||
_M_alloc_fun(alloc_f), _M_free_fun(free_f),
|
||||
_M_dynamic(true), _M_frozen(false), _M_constant(false)
|
||||
{
|
||||
streamsize n = 16;
|
||||
|
||||
char* buf = _M_alloc(n);
|
||||
if (buf) {
|
||||
setp(buf, buf + n);
|
||||
setg(buf, buf, buf);
|
||||
_M_buf_size = _M_buf_size_opt = 16;
|
||||
_M_buf = _M_alloc(_M_buf_size);
|
||||
if (_M_buf)
|
||||
{
|
||||
setp(_M_buf, _M_buf + _M_buf_size);
|
||||
setg(_M_buf, _M_buf, _M_buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +139,14 @@ strstreambuf::strstreambuf(const unsigned char* get, streamsize n)
|
||||
strstreambuf::~strstreambuf()
|
||||
{
|
||||
if (_M_dynamic && !_M_frozen)
|
||||
_M_free(eback());
|
||||
{
|
||||
char* p = this->eback();
|
||||
_M_free(p);
|
||||
if (p == _M_buf)
|
||||
_M_buf = 0;
|
||||
}
|
||||
if (_M_buf)
|
||||
_M_free(_M_buf);
|
||||
}
|
||||
|
||||
void strstreambuf::freeze(bool frozenflag)
|
||||
|
Loading…
Reference in New Issue
Block a user