diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-04-20 00:50:22 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-04-20 00:50:22 +0000 |
| commit | 3505201f3333c937b5b870d70019d400c722a69f (patch) | |
| tree | def64ac6be50375e43da5e3e91eb443dd4c171fc /src/MultiFileAllocationIterator.cc | |
| parent | 99733a84e2102739ee7c9de08ffae9e9216b6003 (diff) | |
2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten SharedHandle. Now copy constructor taking raw pointer
has
keyword explicit and SharedHandle's default constructor
initializes
its internal obj to null, old implementation initializes it
using
obj's default constructor.
To assign null, write SharedHandle<T> x(...); x.reset();
TODO: test/SharedHandleTest.cc needs more tests.
* src/SharedHandle.h
Diffstat (limited to 'src/MultiFileAllocationIterator.cc')
| -rw-r--r-- | src/MultiFileAllocationIterator.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/MultiFileAllocationIterator.cc b/src/MultiFileAllocationIterator.cc index e4125b35..0af7628b 100644 --- a/src/MultiFileAllocationIterator.cc +++ b/src/MultiFileAllocationIterator.cc @@ -44,7 +44,6 @@ MultiFileAllocationIterator::MultiFileAllocationIterator(MultiDiskAdaptor* diskA _diskAdaptor(diskAdaptor), _entries(makeDiskWriterEntries(diskAdaptor->diskWriterEntries, diskAdaptor->getPieceLength())), - _fileAllocationIterator(0), _offset(0) {} @@ -61,10 +60,10 @@ void MultiFileAllocationIterator::allocateChunk() FileEntryHandle fileEntry = entry->getFileEntry(); if(entry->size() < fileEntry->getLength()) { entry->getDiskWriter()->enableDirectIO(); - _fileAllocationIterator = - new SingleFileAllocationIterator(entry->getDiskWriter().get(), - entry->size(), - fileEntry->getLength()); + _fileAllocationIterator.reset + (new SingleFileAllocationIterator(entry->getDiskWriter().get(), + entry->size(), + fileEntry->getLength())); _fileAllocationIterator->init(); } } @@ -114,7 +113,11 @@ DiskWriterEntries MultiFileAllocationIterator::makeDiskWriterEntries(const DiskW return entries; } DiskWriterEntries temp(srcEntries); - temp.push_front(new DiskWriterEntry(new FileEntry())); + { + SharedHandle<FileEntry> f(new FileEntry()); + SharedHandle<DiskWriterEntry> e(new DiskWriterEntry(f)); + temp.push_front(e); + } DiskWriterEntries entries; DiskWriterEntries::const_iterator done = temp.begin(); for(DiskWriterEntries::const_iterator itr = temp.begin()+1; itr != temp.end(); ++itr) { |
