diff --git a/arangod/RocksDBEngine/RocksDBKey.cpp b/arangod/RocksDBEngine/RocksDBKey.cpp index f3a9522a4e..093aa4b147 100644 --- a/arangod/RocksDBEngine/RocksDBKey.cpp +++ b/arangod/RocksDBEngine/RocksDBKey.cpp @@ -33,6 +33,24 @@ using namespace arangodb::rocksutils; const char RocksDBKey::_stringSeparator = '\0'; +RocksDBKey::RocksDBKey(std::string* leased) + : _type(RocksDBEntryType::Document), // placeholder + _local(), + _buffer(leased != nullptr ? leased : &_local) {} + +RocksDBKey::RocksDBKey(rocksdb::Slice slice) + : _type(static_cast(slice.data()[0])), + _local(slice.data(), slice.size()), + _buffer(&_local) {} + +RocksDBKey::RocksDBKey(RocksDBKey&& other) noexcept + : _type(other._type), + _local(), + _buffer(&_local) { + _local.assign(std::move(*(other._buffer))); + other._buffer = &(other._local); +} + /// @brief verify that a key actually contains the given local document id bool RocksDBKey::containsLocalDocumentId(LocalDocumentId const& documentId) const { switch (_type) { diff --git a/arangod/RocksDBEngine/RocksDBKey.h b/arangod/RocksDBEngine/RocksDBKey.h index 6d48809dd5..d685ef07e5 100644 --- a/arangod/RocksDBEngine/RocksDBKey.h +++ b/arangod/RocksDBEngine/RocksDBKey.h @@ -47,23 +47,11 @@ class RocksDBKey { /// @brief construct a leased RocksDBKey /// @param leased will use _local std::string if nullptr - explicit RocksDBKey(std::string* leased) - : _type(RocksDBEntryType::Document), // placeholder - _local(), - _buffer(leased != nullptr ? leased : &_local) {} + explicit RocksDBKey(std::string* leased); - explicit RocksDBKey(rocksdb::Slice slice) - : _type(static_cast(slice.data()[0])), - _local(slice.data(), slice.size()), - _buffer(&_local) {} + explicit RocksDBKey(rocksdb::Slice slice); - RocksDBKey(RocksDBKey&& other) noexcept - : _type(other._type), - _local(), - _buffer(&_local) { - _local.assign(std::move(*(other._buffer))); - other._buffer = &(other._local); - } + RocksDBKey(RocksDBKey&& other) noexcept; RocksDBKey& operator=(RocksDBKey const& other) = delete; RocksDBKey& operator=(RocksDBKey&& other) = delete; diff --git a/arangod/Transaction/Context.cpp b/arangod/Transaction/Context.cpp index 34dfa09a94..04c397c8ad 100644 --- a/arangod/Transaction/Context.cpp +++ b/arangod/Transaction/Context.cpp @@ -98,11 +98,14 @@ transaction::Context::~Context() { delete it; } + // clear all strings handed out + for (auto& it : _strings) { + delete it; + } + if (_ownsResolver) { delete _resolver; } - - _resolver = nullptr; } /// @brief factory to create a custom type handler, not managed