From fa9f3fb5a3c8912a0a6880ffba9c72f4424ea044 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 23 Jun 2013 21:55:52 +0900 Subject: Wrap Command object in std::unique_ptr --- src/RequestGroupEntry.cc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/RequestGroupEntry.cc') diff --git a/src/RequestGroupEntry.cc b/src/RequestGroupEntry.cc index c5aef0bf..8241e52a 100644 --- a/src/RequestGroupEntry.cc +++ b/src/RequestGroupEntry.cc @@ -40,9 +40,9 @@ namespace aria2 { RequestGroupEntry::RequestGroupEntry(RequestGroup* requestGroup, - Command* nextCommand): + std::unique_ptr nextCommand): requestGroup_(requestGroup), - nextCommand_(nextCommand) + nextCommand_(std::move(nextCommand)) { requestGroup_->increaseNumCommand(); } @@ -50,20 +50,16 @@ RequestGroupEntry::RequestGroupEntry(RequestGroup* requestGroup, RequestGroupEntry::~RequestGroupEntry() { requestGroup_->decreaseNumCommand(); - delete nextCommand_; } -Command* RequestGroupEntry::popNextCommand() +std::unique_ptr RequestGroupEntry::popNextCommand() { - Command* temp = nextCommand_; - nextCommand_ = 0; - return temp; + return std::move(nextCommand_); } -void RequestGroupEntry::pushNextCommand(Command* nextCommand) +void RequestGroupEntry::pushNextCommand(std::unique_ptr nextCommand) { - delete nextCommand_; - nextCommand_ = nextCommand; + nextCommand_ = std::move(nextCommand); } } // namespace aria2 -- cgit