diff --git a/db/db_impl.cc b/db/db_impl.cc index a49d595c9..fd9a0d533 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -894,8 +894,9 @@ Status DBImpl::GetUpdatesSince(SequenceNumber seq, } // std::shared_ptr would have been useful here. - std::vector* probableWALFiles = new std::vector(); - s = FindProbableWALFiles(&walFiles, probableWALFiles, seq); + std::unique_ptr> probableWALFiles( + new std::vector()); + s = FindProbableWALFiles(&walFiles, probableWALFiles.get(), seq); if (!s.ok()) { return s; } @@ -904,7 +905,7 @@ Status DBImpl::GetUpdatesSince(SequenceNumber seq, &options_, storage_options_, seq, - probableWALFiles, + std::move(probableWALFiles), &last_flushed_sequence_)); iter->get()->Next(); return iter->get()->status(); diff --git a/db/transaction_log_iterator_impl.cc b/db/transaction_log_iterator_impl.cc index a6edac238..1b0f25b2e 100644 --- a/db/transaction_log_iterator_impl.cc +++ b/db/transaction_log_iterator_impl.cc @@ -9,18 +9,18 @@ TransactionLogIteratorImpl::TransactionLogIteratorImpl( const Options* options, const StorageOptions& soptions, SequenceNumber& seq, - std::vector* files, + std::unique_ptr> files, SequenceNumber const * const lastFlushedSequence) : dbname_(dbname), options_(options), soptions_(soptions), startingSequenceNumber_(seq), - files_(files), + files_(std::move(files)), started_(false), isValid_(false), currentFileIndex_(0), lastFlushedSequence_(lastFlushedSequence) { - assert(files_ != nullptr); + assert(files_.get() != nullptr); assert(lastFlushedSequence_); } @@ -73,7 +73,7 @@ bool TransactionLogIteratorImpl::Valid() { } void TransactionLogIteratorImpl::Next() { - LogFile currentLogFile = files_->at(currentFileIndex_); + LogFile currentLogFile = files_.get()->at(currentFileIndex_); LogReporter reporter = NewLogReporter(currentLogFile.logNumber); // First seek to the given seqNo. in the current file. @@ -134,9 +134,9 @@ void TransactionLogIteratorImpl::Next() { } if (openNextFile) { - if (currentFileIndex_ < files_->size() - 1) { + if (currentFileIndex_ < files_.get()->size() - 1) { ++currentFileIndex_; - Status status = OpenLogReader(files_->at(currentFileIndex_)); + Status status = OpenLogReader(files_.get()->at(currentFileIndex_)); if (!status.ok()) { isValid_ = false; currentStatus_ = status; diff --git a/db/transaction_log_iterator_impl.h b/db/transaction_log_iterator_impl.h index fccbb1505..f682fabc7 100644 --- a/db/transaction_log_iterator_impl.h +++ b/db/transaction_log_iterator_impl.h @@ -30,14 +30,9 @@ class TransactionLogIteratorImpl : public TransactionLogIterator { const Options* options, const StorageOptions& soptions, SequenceNumber& seqNum, - std::vector* files, + std::unique_ptr> files, SequenceNumber const * const lastFlushedSequence); - virtual ~TransactionLogIteratorImpl() { - // TODO move to cc file. - delete files_; - } - virtual bool Valid(); virtual void Next(); @@ -51,7 +46,7 @@ class TransactionLogIteratorImpl : public TransactionLogIterator { const Options* options_; const StorageOptions& soptions_; const uint64_t startingSequenceNumber_; - const std::vector* files_; + std::unique_ptr> files_; bool started_; bool isValid_; // not valid when it starts of. Status currentStatus_;