From 3505201f3333c937b5b870d70019d400c722a69f Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 20 Apr 2008 00:50:22 +0000 Subject: 2008-04-20 Tatsuhiro Tsujikawa 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 x(...); x.reset(); TODO: test/SharedHandleTest.cc needs more tests. * src/SharedHandle.h --- src/UTPexExtensionMessage.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/UTPexExtensionMessage.cc') diff --git a/src/UTPexExtensionMessage.cc b/src/UTPexExtensionMessage.cc index 603b38d6..5139ece3 100644 --- a/src/UTPexExtensionMessage.cc +++ b/src/UTPexExtensionMessage.cc @@ -52,14 +52,13 @@ namespace aria2 { const std::string UTPexExtensionMessage::EXTENSION_NAME = "ut_pex"; UTPexExtensionMessage::UTPexExtensionMessage(uint8_t extensionMessageID): - _extensionMessageID(extensionMessageID), - _btContext(0) {} + _extensionMessageID(extensionMessageID) {} UTPexExtensionMessage::~UTPexExtensionMessage() {} std::string UTPexExtensionMessage::getBencodedData() { - SharedHandle d = new Dictionary(); + SharedHandle d(new Dictionary()); std::pair freshPeerPair = createCompactPeerListAndFlag(_freshPeers); std::pair droppedPeerPair = createCompactPeerListAndFlag(_droppedPeers); d->put("added", new Data(freshPeerPair.first)); @@ -129,8 +128,8 @@ UTPexExtensionMessage::create(const BtContextHandle& btContext, throw new DlAbortEx(MSG_TOO_SMALL_PAYLOAD_SIZE, EXTENSION_NAME.c_str(), len); } - UTPexExtensionMessageHandle msg = new UTPexExtensionMessage(*data); - SharedHandle root = MetaFileUtil::bdecoding(data+1, len-1); + UTPexExtensionMessageHandle msg(new UTPexExtensionMessage(*data)); + SharedHandle root(MetaFileUtil::bdecoding(data+1, len-1)); if(root.isNull()) { return msg; } -- cgit