Skip to content

Commit bfd737a

Browse files
authored
Supervised Buffer implementation (#172)
* Introduce supervised buffer template, must fix Builder.cpp to accomodate it * Intermediate commit of the supervised buffer, must fix template errors still * Make destructor virtual * Restore files to their original state from main branch so just Buffer is changed * Restored Builder to its original state * Make clear method virtual * Make grow method protected
1 parent 8f0fc65 commit bfd737a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

include/velocypack/Buffer.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class Buffer {
132132
return *this;
133133
}
134134

135-
~Buffer() {
135+
virtual ~Buffer() {
136136
if (_buffer != _local) {
137137
velocypack_free(_buffer);
138138
}
@@ -181,7 +181,7 @@ class Buffer {
181181
_size -= value;
182182
}
183183

184-
void clear() noexcept {
184+
virtual void clear() noexcept {
185185
_size = 0;
186186
if (_buffer != _local) {
187187
velocypack_free(_buffer);
@@ -194,7 +194,7 @@ class Buffer {
194194

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

200200
auto buffer = _buffer;
@@ -284,7 +284,9 @@ class Buffer {
284284
inline void poison(T*, ValueLength) noexcept {}
285285
#endif
286286

287-
void grow(ValueLength len) {
287+
protected:
288+
289+
virtual void grow(ValueLength len) {
288290
VELOCYPACK_ASSERT(_size + len >= sizeof(_local));
289291

290292
// need reallocation
@@ -319,6 +321,8 @@ class Buffer {
319321
VELOCYPACK_ASSERT(_size <= _capacity);
320322
}
321323

324+
private:
325+
322326
T* _buffer;
323327
ValueLength _capacity;
324328
ValueLength _size;

0 commit comments

Comments
 (0)