Unverified Commit 2088c8d4 authored by dorianzheng's avatar dorianzheng Committed by GitHub

fix shared_ptr misuse (#271)

parent dc16c9b1
...@@ -2258,8 +2258,8 @@ void crocksdb_options_enable_statistics(crocksdb_options_t* opt, unsigned char v ...@@ -2258,8 +2258,8 @@ void crocksdb_options_enable_statistics(crocksdb_options_t* opt, unsigned char v
} }
void crocksdb_options_reset_statistics(crocksdb_options_t* opt) { void crocksdb_options_reset_statistics(crocksdb_options_t* opt) {
auto statistics = opt->rep.statistics.get(); if (opt->rep.statistics) {
if (statistics) { auto* statistics = opt->rep.statistics.get();
statistics->Reset(); statistics->Reset();
} }
} }
...@@ -2684,8 +2684,8 @@ void crocksdb_options_set_delayed_write_rate(crocksdb_options_t *opt, uint64_t d ...@@ -2684,8 +2684,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) { char *crocksdb_options_statistics_get_string(crocksdb_options_t *opt) {
rocksdb::Statistics *statistics = opt->rep.statistics.get(); if (opt->rep.statistics) {
if (statistics) { rocksdb::Statistics* statistics = opt->rep.statistics.get();
return strdup(statistics->ToString().c_str()); return strdup(statistics->ToString().c_str());
} }
return nullptr; return nullptr;
...@@ -2693,8 +2693,8 @@ char *crocksdb_options_statistics_get_string(crocksdb_options_t *opt) { ...@@ -2693,8 +2693,8 @@ char *crocksdb_options_statistics_get_string(crocksdb_options_t *opt) {
uint64_t crocksdb_options_statistics_get_ticker_count(crocksdb_options_t* opt, uint64_t crocksdb_options_statistics_get_ticker_count(crocksdb_options_t* opt,
uint32_t ticker_type) { uint32_t ticker_type) {
rocksdb::Statistics* statistics = opt->rep.statistics.get(); if (opt->rep.statistics) {
if (statistics) { rocksdb::Statistics* statistics = opt->rep.statistics.get();
return statistics->getTickerCount(ticker_type); return statistics->getTickerCount(ticker_type);
} }
return 0; return 0;
...@@ -2702,8 +2702,8 @@ uint64_t crocksdb_options_statistics_get_ticker_count(crocksdb_options_t* opt, ...@@ -2702,8 +2702,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, uint64_t crocksdb_options_statistics_get_and_reset_ticker_count(crocksdb_options_t* opt,
uint32_t ticker_type) { uint32_t ticker_type) {
rocksdb::Statistics* statistics = opt->rep.statistics.get(); if (opt->rep.statistics) {
if (statistics) { rocksdb::Statistics* statistics = opt->rep.statistics.get();
return statistics->getAndResetTickerCount(ticker_type); return statistics->getAndResetTickerCount(ticker_type);
} }
return 0; return 0;
...@@ -2711,8 +2711,8 @@ uint64_t crocksdb_options_statistics_get_and_reset_ticker_count(crocksdb_options ...@@ -2711,8 +2711,8 @@ uint64_t crocksdb_options_statistics_get_and_reset_ticker_count(crocksdb_options
char* crocksdb_options_statistics_get_histogram_string(crocksdb_options_t* opt, char* crocksdb_options_statistics_get_histogram_string(crocksdb_options_t* opt,
uint32_t type) { uint32_t type) {
rocksdb::Statistics* statistics = opt->rep.statistics.get(); if (opt->rep.statistics) {
if (statistics) { rocksdb::Statistics* statistics = opt->rep.statistics.get();
return strdup(statistics->getHistogramString(type).c_str()); return strdup(statistics->getHistogramString(type).c_str());
} }
return nullptr; return nullptr;
...@@ -2727,8 +2727,8 @@ unsigned char crocksdb_options_statistics_get_histogram( ...@@ -2727,8 +2727,8 @@ unsigned char crocksdb_options_statistics_get_histogram(
double* average, double* average,
double* standard_deviation, double* standard_deviation,
double* max) { double* max) {
rocksdb::Statistics* statistics = opt->rep.statistics.get(); if (opt->rep.statistics) {
if (statistics) { rocksdb::Statistics* statistics = opt->rep.statistics.get();
crocksdb_histogramdata_t data; crocksdb_histogramdata_t data;
statistics->histogramData(type, &data.rep); statistics->histogramData(type, &data.rep);
*median = data.rep.median; *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