util/WritableBuffer: add method MoveFront()

This commit is contained in:
Max Kellermann 2017-07-05 17:10:59 +02:00
parent 19358d1c42
commit b04679b429

View File

@ -235,6 +235,20 @@ struct WritableBuffer {
data += n;
size -= n;
}
/**
* Move the front pointer to the given address, and adjust the
* size attribute to retain the old end address.
*/
void MoveFront(pointer_type new_data) {
#ifndef NDEBUG
assert(IsNull() == (new_data == nullptr));
assert(new_data <= end());
#endif
size = end() - new_data;
data = new_data;
}
};
#endif