mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 11:05:03 +02:00
GH #305: There are bugs in Buffer.h
This commit is contained in:
@@ -142,7 +142,7 @@ public:
|
||||
{
|
||||
T* ptr = new T[newCapacity];
|
||||
if (preserveContent)
|
||||
std::memcpy(ptr, _ptr, _used);
|
||||
std::memcpy(ptr, _ptr, _used * sizeof(T));
|
||||
|
||||
delete [] _ptr;
|
||||
_ptr = ptr;
|
||||
@@ -171,7 +171,10 @@ public:
|
||||
{
|
||||
T* ptr = new T[newCapacity];
|
||||
if (preserveContent)
|
||||
std::memcpy(ptr, _ptr, _used < newCapacity ? _used : newCapacity);
|
||||
{
|
||||
std::size_t newSz = _used < newCapacity ? _used : newCapacity;
|
||||
std::memcpy(ptr, _ptr, newSz * sizeof(T));
|
||||
}
|
||||
|
||||
delete [] _ptr;
|
||||
_ptr = ptr;
|
||||
@@ -187,7 +190,7 @@ public:
|
||||
{
|
||||
if (0 == sz) return;
|
||||
if (sz > _capacity) resize(sz, false);
|
||||
std::memcpy(_ptr, buf, sz);
|
||||
std::memcpy(_ptr, buf, sz * sizeof(T));
|
||||
_used = sz;
|
||||
}
|
||||
|
||||
@@ -196,7 +199,7 @@ public:
|
||||
{
|
||||
if (0 == sz) return;
|
||||
resize(_used + sz, true);
|
||||
std::memcpy(_ptr + _used - sz, buf, sz);
|
||||
std::memcpy(_ptr + _used - sz, buf, sz * sizeof(T));
|
||||
}
|
||||
|
||||
void append(T val)
|
||||
@@ -241,7 +244,7 @@ public:
|
||||
{
|
||||
if (_used == other._used)
|
||||
{
|
||||
if (std::memcmp(_ptr, other._ptr, _used) == 0)
|
||||
if (std::memcmp(_ptr, other._ptr, _used * sizeof(T)) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user