diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-07-05 21:54:07 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-07-06 15:56:08 +0900 |
| commit | f8d305fe639a2a458106f3f233f696157c6ab06d (patch) | |
| tree | c55db59952332c1f29e665d44781a82bf2580f83 /src/AdaptiveFileAllocationIterator.cc | |
| parent | 345ba415a50fbf99b1f0049f29be62d0bd11c608 (diff) | |
Use std::unique_ptr for FileAllocationIterator
Diffstat (limited to 'src/AdaptiveFileAllocationIterator.cc')
| -rw-r--r-- | src/AdaptiveFileAllocationIterator.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/AdaptiveFileAllocationIterator.cc b/src/AdaptiveFileAllocationIterator.cc index f4a116ef..36a2e928 100644 --- a/src/AdaptiveFileAllocationIterator.cc +++ b/src/AdaptiveFileAllocationIterator.cc @@ -38,6 +38,7 @@ #include "RecoverableException.h" #include "LogFactory.h" #include "Logger.h" +#include "a2functional.h" #ifdef HAVE_FALLOCATE # include "FallocFileAllocationIterator.h" #endif // HAVE_FALLOCATE @@ -66,20 +67,20 @@ void AdaptiveFileAllocationIterator::allocateChunk() offset_ += len; } A2_LOG_DEBUG("File system supports fallocate."); - allocator_.reset - (new FallocFileAllocationIterator(stream_, offset_, totalLength_)); + allocator_ = make_unique<FallocFileAllocationIterator> + (stream_, offset_, totalLength_); } catch(RecoverableException& e) { A2_LOG_DEBUG("File system does not support fallocate."); - std::shared_ptr<SingleFileAllocationIterator> salloc - (new SingleFileAllocationIterator(stream_, offset_, totalLength_)); + auto salloc = make_unique<SingleFileAllocationIterator> + (stream_, offset_, totalLength_); salloc->init(); - allocator_ = salloc; + allocator_ = std::move(salloc); } #else // !HAVE_FALLOCATE - std::shared_ptr<SingleFileAllocationIterator> salloc - (new SingleFileAllocationIterator(stream_, offset_, totalLength_)); + auto salloc = make_unique<SingleFileAllocationIterator> + (stream_, offset_, totalLength_); salloc->init(); - allocator_ = salloc; + allocator_ = std::move(salloc); #endif // !HAVE_FALLOCATE allocator_->allocateChunk(); } else { |
