From b1031d6c12df66f707a86b4d7c5e8928835ea93b Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 14 Oct 2016 13:09:18 -0700 Subject: [PATCH] Remove function local statics that interfere with memory pooling (#1392) --- util/options_helper.cc | 6 ++++-- util/options_helper.h | 1 + util/options_parser.cc | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/util/options_helper.cc b/util/options_helper.cc index e9eb20f3b..9f80f3634 100644 --- a/util/options_helper.cc +++ b/util/options_helper.cc @@ -26,6 +26,8 @@ namespace rocksdb { +const std::string kNullptrString = "nullptr"; + DBOptions BuildDBOptions(const ImmutableDBOptions& immutable_db_options, const MutableDBOptions& mutable_db_options) { DBOptions options; @@ -451,7 +453,7 @@ bool ParseSliceTransformHelper( const std::string& kFixedPrefixName, const std::string& kCappedPrefixName, const std::string& value, std::shared_ptr* slice_transform) { - static const std::string kNullptrString = "nullptr"; + auto& pe_value = value; if (pe_value.size() > kFixedPrefixName.size() && pe_value.compare(0, kFixedPrefixName.size(), kFixedPrefixName) == 0) { @@ -577,7 +579,7 @@ bool ParseOptionHelper(char* opt_address, const OptionType& opt_type, bool SerializeSingleOptionHelper(const char* opt_address, const OptionType opt_type, std::string* value) { - static const std::string kNullptrString = "nullptr"; + assert(value); switch (opt_type) { case OptionType::kBoolean: diff --git a/util/options_helper.h b/util/options_helper.h index f87e28997..037146a88 100644 --- a/util/options_helper.h +++ b/util/options_helper.h @@ -693,6 +693,7 @@ static std::unordered_map info_log_level_string_map = {"FATAL_LEVEL", InfoLogLevel::FATAL_LEVEL}, {"HEADER_LEVEL", InfoLogLevel::HEADER_LEVEL}}; +extern const std::string kNullptrString; #endif // !ROCKSDB_LITE } // namespace rocksdb diff --git a/util/options_parser.cc b/util/options_parser.cc index a49fd9861..a69a00cb5 100644 --- a/util/options_parser.cc +++ b/util/options_parser.cc @@ -510,7 +510,7 @@ bool AreEqualOptions( const std::unordered_map* opt_map) { const char* offset1 = opt1 + type_info.offset; const char* offset2 = opt2 + type_info.offset; - static const std::string kNullptrString = "nullptr"; + switch (type_info.type) { case OptionType::kBoolean: return (*reinterpret_cast(offset1) == -- GitLab