util/ForeignFifoBuffer: use Read() in MoveBuffer() and Shift()

This commit is contained in:
Max Kellermann 2024-11-08 19:48:41 +01:00 committed by Max Kellermann
parent 849c4012c0
commit 8a3b48754e
1 changed files with 5 additions and 3 deletions

View File

@ -97,9 +97,10 @@ public:
}
void MoveBuffer(T *new_data, size_type new_capacity) noexcept {
assert(new_capacity >= tail - head);
const auto r = Read();
assert(new_capacity >= r.size());
std::move(r.begin(), r.end(), new_data);
std::move(data + head, data + tail, new_data);
data = new_data;
capacity = new_capacity;
tail -= head;
@ -231,7 +232,8 @@ protected:
assert(tail <= capacity);
assert(tail >= head);
std::move(data + head, data + tail, data);
const auto r = Read();
std::move(r.begin(), r.end(), data);
tail -= head;
head = 0;