util/ConstBuffer: add method MoveFront()

This commit is contained in:
Max Kellermann 2015-10-16 09:00:36 +02:00
parent 27a40a9843
commit 438b7b7bd0

View File

@ -246,6 +246,20 @@ struct ConstBuffer {
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