ByteVector::append() can't take the vector itself.

This commit is contained in:
Tsuda Kageyu
2016-02-20 19:42:46 +09:00
parent 98a57744c3
commit 7d8aa7b8bd
2 changed files with 20 additions and 8 deletions

View File

@ -554,12 +554,16 @@ int ByteVector::endsWithPartialMatch(const ByteVector &pattern) const
ByteVector &ByteVector::append(const ByteVector &v)
{
if(v.d->length != 0) {
detach();
unsigned int originalSize = size();
resize(originalSize + v.size());
::memcpy(data() + originalSize, v.data(), v.size());
}
if(v.isEmpty())
return *this;
detach();
const unsigned int originalSize = size();
const unsigned int appendSize = v.size();
resize(originalSize + v.size());
::memcpy(data() + originalSize, v.data(), appendSize);
return *this;
}