diff options
author | Max Kellermann <max@duempel.org> | 2015-10-16 09:00:36 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-10-16 09:00:36 +0200 |
commit | 438b7b7bd0a524e97ca30649436c1d8fec850ba3 (patch) | |
tree | 35896cafc72f4d24a1dc3e18e1aefae4137a7b47 /src/util | |
parent | 27a40a984364a1ed2619028babd854a4397a881b (diff) | |
download | mpd-438b7b7bd0a524e97ca30649436c1d8fec850ba3.tar.gz mpd-438b7b7bd0a524e97ca30649436c1d8fec850ba3.tar.xz mpd-438b7b7bd0a524e97ca30649436c1d8fec850ba3.zip |
util/ConstBuffer: add method MoveFront()
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/ConstBuffer.hxx | 14 |
1 files changed, 14 insertions, 0 deletions
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 |