Unverified Commit 5db6e4cc authored by dorianzheng's avatar dorianzheng Committed by GitHub

fix shared_ptr misuse (#271) (#273)

(cherry picked from commit 2088c8d4)
parent d65ca9df
......@@ -2133,8 +2133,8 @@ void crocksdb_options_enable_statistics(crocksdb_options_t* opt, unsigned char v
}
void crocksdb_options_reset_statistics(crocksdb_options_t* opt) {
auto statistics = opt->rep.statistics.get();
if (statistics) {
if (opt->rep.statistics) {
auto* statistics = opt->rep.statistics.get();
statistics->Reset();
}
}
......@@ -2559,8 +2559,8 @@ void crocksdb_options_set_delayed_write_rate(crocksdb_options_t *opt, uint64_t d
}
char *crocksdb_options_statistics_get_string(crocksdb_options_t *opt) {
rocksdb::Statistics *statistics = opt->rep.statistics.get();
if (statistics) {
if (opt->rep.statistics) {
rocksdb::Statistics* statistics = opt->rep.statistics.get();
return strdup(statistics->ToString().c_str());
}
return nullptr;
......@@ -2568,8 +2568,8 @@ char *crocksdb_options_statistics_get_string(crocksdb_options_t *opt) {
uint64_t crocksdb_options_statistics_get_ticker_count(crocksdb_options_t* opt,
uint32_t ticker_type) {
rocksdb::Statistics* statistics = opt->rep.statistics.get();
if (statistics) {
if (opt->rep.statistics) {
rocksdb::Statistics* statistics = opt->rep.statistics.get();
return statistics->getTickerCount(ticker_type);
}
return 0;
......@@ -2577,8 +2577,8 @@ uint64_t crocksdb_options_statistics_get_ticker_count(crocksdb_options_t* opt,
uint64_t crocksdb_options_statistics_get_and_reset_ticker_count(crocksdb_options_t* opt,
uint32_t ticker_type) {
rocksdb::Statistics* statistics = opt->rep.statistics.get();
if (statistics) {
if (opt->rep.statistics) {
rocksdb::Statistics* statistics = opt->rep.statistics.get();
return statistics->getAndResetTickerCount(ticker_type);
}
return 0;
......@@ -2586,8 +2586,8 @@ uint64_t crocksdb_options_statistics_get_and_reset_ticker_count(crocksdb_options
char* crocksdb_options_statistics_get_histogram_string(crocksdb_options_t* opt,
uint32_t type) {
rocksdb::Statistics* statistics = opt->rep.statistics.get();
if (statistics) {
if (opt->rep.statistics) {
rocksdb::Statistics* statistics = opt->rep.statistics.get();
return strdup(statistics->getHistogramString(type).c_str());
}
return nullptr;
......@@ -2602,8 +2602,8 @@ unsigned char crocksdb_options_statistics_get_histogram(
double* average,
double* standard_deviation,
double* max) {
rocksdb::Statistics* statistics = opt->rep.statistics.get();
if (statistics) {
if (opt->rep.statistics) {
rocksdb::Statistics* statistics = opt->rep.statistics.get();
crocksdb_histogramdata_t data;
statistics->histogramData(type, &data.rep);
*median = data.rep.median;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment