提交 4d7c06ce 编写于 作者: G Giuseppe Ottaviano 提交者: Facebook Github Bot

Make WriteBatchWithIndex moveble

Summary:
`WriteBatchWithIndex` has an incorrect implicitly-generated move constructor (it will copy the pointer causing a double-free on destruction). Just switch to `unique_ptr` so we get correct move semantics for free.
Closes https://github.com/facebook/rocksdb/pull/1899

Differential Revision: D4598896

Pulled By: ajkr

fbshipit-source-id: 2373d47
上级 5040414e
......@@ -12,6 +12,7 @@
#ifndef ROCKSDB_LITE
#include <memory>
#include <string>
#include "rocksdb/comparator.h"
......@@ -205,7 +206,7 @@ class WriteBatchWithIndex : public WriteBatchBase {
private:
struct Rep;
Rep* rep;
std::unique_ptr<Rep> rep;
};
} // namespace rocksdb
......
......@@ -570,7 +570,7 @@ WriteBatchWithIndex::WriteBatchWithIndex(
bool overwrite_key)
: rep(new Rep(default_index_comparator, reserved_bytes, overwrite_key)) {}
WriteBatchWithIndex::~WriteBatchWithIndex() { delete rep; }
WriteBatchWithIndex::~WriteBatchWithIndex() {}
WriteBatch* WriteBatchWithIndex::GetWriteBatch() { return &rep->write_batch; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册