Commit 855750c7 authored by Max Kellermann's avatar Max Kellermann

util/{Const,Writable}Buffer: add method SetEnd()

parent 4f2163e7
...@@ -289,6 +289,19 @@ struct ConstBuffer { ...@@ -289,6 +289,19 @@ struct ConstBuffer {
size = end() - new_data; size = end() - new_data;
data = 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 #endif
...@@ -278,6 +278,19 @@ struct WritableBuffer { ...@@ -278,6 +278,19 @@ struct WritableBuffer {
size = end() - new_data; size = end() - new_data;
data = 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 #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment