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/PeerInitiateConnectionCommand.cc | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/PeerInitiateConnectionCommand.cc') 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 + (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 + (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 = peerStorage_->checkoutPeer(ncuid); // sanity check if(peer) { - PeerInitiateConnectionCommand* command; - command = new PeerInitiateConnectionCommand(ncuid, requestGroup_, peer, - getDownloadEngine(), - btRuntime_); + auto command = make_unique + (ncuid, requestGroup_, peer, getDownloadEngine(), btRuntime_); command->setPeerStorage(peerStorage_); command->setPieceStorage(pieceStorage_); - getDownloadEngine()->addCommand(command); + getDownloadEngine()->addCommand(std::move(command)); } } return true; -- cgit