summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-08-21 08:20:17 +0200
committerMax Kellermann <max@musicpd.org>2018-08-21 08:20:17 +0200
commit855750c784a391c3a5fe5658c61a67cceb18d676 (patch)
tree2f0c13eb6a31fbed90665877276a8720d68978e1 /src/util
parent4f2163e76c98ab0c3833e71be42c2ed546150a55 (diff)
util/{Const,Writable}Buffer: add method SetEnd()
Diffstat (limited to 'src/util')
-rw-r--r--src/util/ConstBuffer.hxx13
-rw-r--r--src/util/WritableBuffer.hxx13
2 files changed, 26 insertions, 0 deletions
diff --git a/src/util/ConstBuffer.hxx b/src/util/ConstBuffer.hxx
index 74fe297b5..ad795911e 100644
--- a/src/util/ConstBuffer.hxx
+++ b/src/util/ConstBuffer.hxx
@@ -289,6 +289,19 @@ struct ConstBuffer {
size = end() - new_data;
data = new_data;
}
+
+ /**
+ * Move the end pointer to the given address (by adjusting the
+ * size).
+ */
+ void SetEnd(pointer_type new_end) {
+#ifndef NDEBUG
+ assert(IsNull() == (new_end == nullptr));
+ assert(new_end >= begin());
+#endif
+
+ size = new_end - data;
+ }
};
#endif
diff --git a/src/util/WritableBuffer.hxx b/src/util/WritableBuffer.hxx
index 696ae8910..4919d8487 100644
--- a/src/util/WritableBuffer.hxx
+++ b/src/util/WritableBuffer.hxx
@@ -278,6 +278,19 @@ struct WritableBuffer {
size = end() - new_data;
data = new_data;
}
+
+ /**
+ * Move the end pointer to the given address (by adjusting the
+ * size).
+ */
+ void SetEnd(pointer_type new_end) {
+#ifndef NDEBUG
+ assert(IsNull() == (new_end == nullptr));
+ assert(new_end >= begin());
+#endif
+
+ size = new_end - data;
+ }
};
#endif