mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Revert the last two commits.
But leave the tests unchanged, and add some comments.
This commit is contained in:
parent
1f99c93a61
commit
b021ed44e9
@ -703,15 +703,12 @@ ByteVector &ByteVector::resize(uint size, char padding)
|
||||
if(size != d->length) {
|
||||
detach();
|
||||
|
||||
const size_t bufferSize = d->data->data.size();
|
||||
// Remove the excessive length of the internal buffer first to pad correctly.
|
||||
// This doesn't reallocate the buffer, since std::vector::resize() doesn't
|
||||
// reallocate the buffer when shrinking.
|
||||
|
||||
if(size > bufferSize - d->offset) {
|
||||
d->data->data.resize(d->offset + size, padding);
|
||||
::memset(&*end(), padding, bufferSize - (d->length + d->offset));
|
||||
}
|
||||
else if(size > d->length) {
|
||||
::memset(&*end(), padding, size - d->length);
|
||||
}
|
||||
d->data->data.resize(d->offset + d->length);
|
||||
d->data->data.resize(d->offset + size, padding);
|
||||
|
||||
d->length = size;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user