aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-10-16 09:00:36 +0200
committerMax Kellermann <max@duempel.org>2015-10-16 09:00:36 +0200
commit438b7b7bd0a524e97ca30649436c1d8fec850ba3 (patch)
tree35896cafc72f4d24a1dc3e18e1aefae4137a7b47 /src
parent27a40a984364a1ed2619028babd854a4397a881b (diff)
downloadmpd-438b7b7bd0a524e97ca30649436c1d8fec850ba3.tar.gz
mpd-438b7b7bd0a524e97ca30649436c1d8fec850ba3.tar.xz
mpd-438b7b7bd0a524e97ca30649436c1d8fec850ba3.zip
util/ConstBuffer: add method MoveFront()
Diffstat (limited to 'src')
-rw-r--r--src/util/ConstBuffer.hxx14
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