diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-23 21:55:52 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-23 21:55:52 +0900 |
| commit | fa9f3fb5a3c8912a0a6880ffba9c72f4424ea044 (patch) | |
| tree | deb0b47b085a3a689bf386409734bfd3f72f57d2 /src/PeerInitiateConnectionCommand.cc | |
| parent | bb5b7eeedb3ce7396007818cbab4f5f5660997a5 (diff) | |
Wrap Command object in std::unique_ptr
Diffstat (limited to 'src/PeerInitiateConnectionCommand.cc')
| -rw-r--r-- | src/PeerInitiateConnectionCommand.cc | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/PeerInitiateConnectionCommand.cc b/src/PeerInitiateConnectionCommand.cc index 118163ce..384af239 100644 --- a/src/PeerInitiateConnectionCommand.cc +++ b/src/PeerInitiateConnectionCommand.cc @@ -84,20 +84,20 @@ bool PeerInitiateConnectionCommand::executeInternal() { getSocket()->establishConnection(getPeer()->getIPAddress(), getPeer()->getPort(), false); if(mseHandshakeEnabled_) { - InitiatorMSEHandshakeCommand* c = - new InitiatorMSEHandshakeCommand(getCuid(), requestGroup_, getPeer(), - getDownloadEngine(), - btRuntime_, getSocket()); + auto c = make_unique<InitiatorMSEHandshakeCommand> + (getCuid(), requestGroup_, getPeer(), + getDownloadEngine(), btRuntime_, getSocket()); c->setPeerStorage(peerStorage_); c->setPieceStorage(pieceStorage_); - getDownloadEngine()->addCommand(c); + getDownloadEngine()->addCommand(std::move(c)); } else { - PeerInteractionCommand* command = - new PeerInteractionCommand - (getCuid(), requestGroup_, getPeer(), getDownloadEngine(), - btRuntime_, pieceStorage_, peerStorage_, - getSocket(), PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE); - getDownloadEngine()->addCommand(command); + getDownloadEngine()->addCommand + (make_unique<PeerInteractionCommand> + (getCuid(), requestGroup_, getPeer(), + getDownloadEngine(), + btRuntime_, pieceStorage_, peerStorage_, + getSocket(), + PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE)); } return true; } @@ -109,13 +109,11 @@ bool PeerInitiateConnectionCommand::prepareForNextPeer(time_t wait) { std::shared_ptr<Peer> peer = peerStorage_->checkoutPeer(ncuid); // sanity check if(peer) { - PeerInitiateConnectionCommand* command; - command = new PeerInitiateConnectionCommand(ncuid, requestGroup_, peer, - getDownloadEngine(), - btRuntime_); + auto command = make_unique<PeerInitiateConnectionCommand> + (ncuid, requestGroup_, peer, getDownloadEngine(), btRuntime_); command->setPeerStorage(peerStorage_); command->setPieceStorage(pieceStorage_); - getDownloadEngine()->addCommand(command); + getDownloadEngine()->addCommand(std::move(command)); } } return true; |
