From 438b7b7bd0a524e97ca30649436c1d8fec850ba3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Oct 2015 09:00:36 +0200 Subject: util/ConstBuffer: add method MoveFront() --- src/util/ConstBuffer.hxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/util/ConstBuffer.hxx') diff --git a/src/util/ConstBuffer.hxx b/src/util/ConstBuffer.hxx index 4d0a49e98..b98a8b543 100644 --- a/src/util/ConstBuffer.hxx +++ b/src/util/ConstBuffer.hxx @@ -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 -- cgit v1.2.3