diff --git a/deps/ox/src/ox/ptrarith/nodebuffer.hpp b/deps/ox/src/ox/ptrarith/nodebuffer.hpp index 920e1618..4ab16e7d 100644 --- a/deps/ox/src/ox/ptrarith/nodebuffer.hpp +++ b/deps/ox/src/ox/ptrarith/nodebuffer.hpp @@ -75,6 +75,8 @@ class __attribute__((packed)) NodeBuffer { public: NodeBuffer() = default; + NodeBuffer(const NodeBuffer &other); + explicit NodeBuffer(size_t size); const Iterator iterator() const; @@ -120,9 +122,11 @@ class __attribute__((packed)) NodeBuffer { */ size_t spaceNeeded(size_t size); - private: - void compact(void (*cb)(ItemPtr itemMoved)); + void compact(void (*cb)(ItemPtr itemMoved) = nullptr); + void truncate(); + + private: uint8_t *data(); }; @@ -132,6 +136,11 @@ NodeBuffer::NodeBuffer(size_t size) { m_header.size = size; } +template +NodeBuffer::NodeBuffer(const NodeBuffer &other) { + ox_memcpy(this, &other, other.size()); +} + template const typename NodeBuffer::Iterator NodeBuffer::iterator() const { return Iterator(this, firstItem()); @@ -314,6 +323,11 @@ void NodeBuffer::compact(void (*cb)(ItemPtr)) { } } +template +void NodeBuffer::truncate() { + m_header.size = m_header.bytesUsed; +} + template uint8_t *NodeBuffer::data() { return reinterpret_cast(ptr(sizeof(*this)).get());