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