switched over buffer to use realloc/free

This commit is contained in:
Arvid Norberg 2009-11-11 05:24:57 +00:00
parent 4b52b57bf0
commit ac0f9d8f9c
1 changed files with 4 additions and 6 deletions

View File

@ -116,6 +116,7 @@ public:
buffer& operator=(buffer const& b)
{
if (&b == this) return *this;
resize(b.size());
std::memcpy(m_begin, b.begin(), b.size());
return *this;
@ -123,7 +124,7 @@ public:
~buffer()
{
::operator delete (m_begin);
std::free(m_begin);
}
buffer::interval data() { return interval(m_begin, m_end); }
@ -172,12 +173,9 @@ public:
if (n <= capacity()) return;
TORRENT_ASSERT(n > 0);
char* buf = (char*)::operator new(n);
std::size_t s = size();
std::memcpy(buf, m_begin, s);
::operator delete (m_begin);
m_begin = buf;
m_end = buf + s;
m_begin = (char*)std::realloc(m_begin, n);
m_end = m_begin + s;
m_last = m_begin + n;
}