Skip to content

Supervised Buffer implementation #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions include/velocypack/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Buffer {
return *this;
}

~Buffer() {
virtual ~Buffer() {
if (_buffer != _local) {
velocypack_free(_buffer);
}
Expand Down Expand Up @@ -181,7 +181,7 @@ class Buffer {
_size -= value;
}

void clear() noexcept {
virtual void clear() noexcept {
_size = 0;
if (_buffer != _local) {
velocypack_free(_buffer);
Expand All @@ -194,7 +194,7 @@ class Buffer {

// Steal external memory; only allowed when the buffer is not local,
// i.e. !usesLocalMemory()
T* steal() noexcept {
virtual T* steal() noexcept {
VELOCYPACK_ASSERT(!usesLocalMemory());

auto buffer = _buffer;
Expand Down Expand Up @@ -284,7 +284,9 @@ class Buffer {
inline void poison(T*, ValueLength) noexcept {}
#endif

void grow(ValueLength len) {
protected:

virtual void grow(ValueLength len) {
VELOCYPACK_ASSERT(_size + len >= sizeof(_local));

// need reallocation
Expand Down Expand Up @@ -319,6 +321,8 @@ class Buffer {
VELOCYPACK_ASSERT(_size <= _capacity);
}

private:

T* _buffer;
ValueLength _capacity;
ValueLength _size;
Expand Down
Loading