1
0
Fork 0

fix memleaks

This commit is contained in:
jsteemann 2019-04-09 11:24:03 +02:00
parent 2b594bdab5
commit ed1e0336cb
3 changed files with 26 additions and 17 deletions

View File

@ -33,6 +33,24 @@ using namespace arangodb::rocksutils;
const char RocksDBKey::_stringSeparator = '\0'; 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<RocksDBEntryType>(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 /// @brief verify that a key actually contains the given local document id
bool RocksDBKey::containsLocalDocumentId(LocalDocumentId const& documentId) const { bool RocksDBKey::containsLocalDocumentId(LocalDocumentId const& documentId) const {
switch (_type) { switch (_type) {

View File

@ -47,23 +47,11 @@ class RocksDBKey {
/// @brief construct a leased RocksDBKey /// @brief construct a leased RocksDBKey
/// @param leased will use _local std::string if nullptr /// @param leased will use _local std::string if nullptr
explicit RocksDBKey(std::string* leased) explicit RocksDBKey(std::string* leased);
: _type(RocksDBEntryType::Document), // placeholder
_local(),
_buffer(leased != nullptr ? leased : &_local) {}
explicit RocksDBKey(rocksdb::Slice slice) explicit RocksDBKey(rocksdb::Slice slice);
: _type(static_cast<RocksDBEntryType>(slice.data()[0])),
_local(slice.data(), slice.size()),
_buffer(&_local) {}
RocksDBKey(RocksDBKey&& other) noexcept RocksDBKey(RocksDBKey&& other) noexcept;
: _type(other._type),
_local(),
_buffer(&_local) {
_local.assign(std::move(*(other._buffer)));
other._buffer = &(other._local);
}
RocksDBKey& operator=(RocksDBKey const& other) = delete; RocksDBKey& operator=(RocksDBKey const& other) = delete;
RocksDBKey& operator=(RocksDBKey&& other) = delete; RocksDBKey& operator=(RocksDBKey&& other) = delete;

View File

@ -98,11 +98,14 @@ transaction::Context::~Context() {
delete it; delete it;
} }
// clear all strings handed out
for (auto& it : _strings) {
delete it;
}
if (_ownsResolver) { if (_ownsResolver) {
delete _resolver; delete _resolver;
} }
_resolver = nullptr;
} }
/// @brief factory to create a custom type handler, not managed /// @brief factory to create a custom type handler, not managed