diff --git a/db/c.cc b/db/c.cc index 1c32ee69c..bc7239dc1 100644 --- a/db/c.cc +++ b/db/c.cc @@ -143,7 +143,7 @@ struct rocksdb_column_family_handle_t { ColumnFamilyHandle* rep; }; struct rocksdb_envoptions_t { EnvOptions rep; }; struct rocksdb_ingestexternalfileoptions_t { IngestExternalFileOptions rep; }; struct rocksdb_sstfilewriter_t { SstFileWriter* rep; }; -struct rocksdb_ratelimiter_t { RateLimiter* rep; }; +struct rocksdb_ratelimiter_t { shared_ptr rep; }; struct rocksdb_perfcontext_t { PerfContext* rep; }; struct rocksdb_pinnableslice_t { PinnableSlice rep; @@ -2524,8 +2524,9 @@ char *rocksdb_options_statistics_get_string(rocksdb_options_t *opt) { } void rocksdb_options_set_ratelimiter(rocksdb_options_t *opt, rocksdb_ratelimiter_t *limiter) { - opt->rep.rate_limiter.reset(limiter->rep); - limiter->rep = nullptr; + if (limiter) { + opt->rep.rate_limiter = limiter->rep; + } } rocksdb_ratelimiter_t* rocksdb_ratelimiter_create( @@ -2533,15 +2534,13 @@ rocksdb_ratelimiter_t* rocksdb_ratelimiter_create( int64_t refill_period_us, int32_t fairness) { rocksdb_ratelimiter_t* rate_limiter = new rocksdb_ratelimiter_t; - rate_limiter->rep = NewGenericRateLimiter(rate_bytes_per_sec, - refill_period_us, fairness); + rate_limiter->rep.reset( + NewGenericRateLimiter(rate_bytes_per_sec, + refill_period_us, fairness)); return rate_limiter; } void rocksdb_ratelimiter_destroy(rocksdb_ratelimiter_t *limiter) { - if (limiter->rep) { - delete limiter->rep; - } delete limiter; }