Fix valgrind issues

Summary:
NewFixedPrefixTransform is leaked in default options. Broken by b47812fba6

Also included in the diff some code cleanup

Test Plan:
valgrind env_test
also make check

Reviewers: haobo, danguo, yhchiang

Reviewed By: danguo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D17211
This commit is contained in:
Igor Canadi 2014-03-27 08:22:59 -07:00
parent d556200264
commit 1c9f8f0884
4 changed files with 6 additions and 8 deletions

View File

@ -70,7 +70,6 @@ namespace rocksdb {
int DBImpl::SuperVersion::dummy = 0;
void* const DBImpl::SuperVersion::kSVInUse = &DBImpl::SuperVersion::dummy;
void* const DBImpl::SuperVersion::kSVObsolete = nullptr;
const std::string kNullString = "NULL";
void DumpLeveldbBuildVersion(Logger * log);
@ -2897,7 +2896,6 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
assert(compact);
compact->CleanupBatchBuffer();
compact->CleanupMergedBuffer();
compact->cur_prefix_ = kNullString;
bool prefix_initialized = false;
int64_t imm_micros = 0; // Micros spent doing imm_ compactions

View File

@ -139,6 +139,7 @@ class DefaultCompactionFilterFactory : public CompactionFilterFactory {
//
class CompactionFilterFactoryV2 {
public:
// NOTE: CompactionFilterFactoryV2 will not delete prefix_extractor
explicit CompactionFilterFactoryV2(const SliceTransform* prefix_extractor)
: prefix_extractor_(prefix_extractor) { }
@ -169,9 +170,8 @@ class CompactionFilterFactoryV2 {
// return any filter
class DefaultCompactionFilterFactoryV2 : public CompactionFilterFactoryV2 {
public:
explicit DefaultCompactionFilterFactoryV2(
const SliceTransform* prefix_extractor)
: CompactionFilterFactoryV2(prefix_extractor) { }
explicit DefaultCompactionFilterFactoryV2()
: CompactionFilterFactoryV2(nullptr) { }
virtual std::unique_ptr<CompactionFilterV2>
CreateCompactionFilterV2(

View File

@ -126,6 +126,8 @@ struct Options {
// Version TWO of the compaction_filter_factory
// It supports rolling compaction
//
// Default: a factory that doesn't provide any object
std::shared_ptr<CompactionFilterFactoryV2> compaction_filter_factory_v2;
// If true, the database will be created if it is missing.

View File

@ -32,9 +32,7 @@ Options::Options()
compaction_filter(nullptr),
compaction_filter_factory(std::shared_ptr<CompactionFilterFactory>(
new DefaultCompactionFilterFactory())),
compaction_filter_factory_v2(
new DefaultCompactionFilterFactoryV2(
NewFixedPrefixTransform(8))),
compaction_filter_factory_v2(new DefaultCompactionFilterFactoryV2()),
create_if_missing(false),
error_if_exists(false),
paranoid_checks(false),