diff --git a/src/DNSCache.h b/src/DNSCache.h index 501b6fd1..87666c47 100644 --- a/src/DNSCache.h +++ b/src/DNSCache.h @@ -115,7 +115,7 @@ public: void findAll(OutputIterator out, const std::string& hostname, uint16_t port) const { - std::shared_ptr target(new CacheEntry(hostname, port)); + auto target = std::make_shared(hostname, port); auto i = entries_.find(target); if (i != entries_.end()) { (*i)->getAllGoodAddrs(out); diff --git a/src/HttpRequestConnectChain.h b/src/HttpRequestConnectChain.h index 0a5cc9d9..dd3ccaac 100644 --- a/src/HttpRequestConnectChain.h +++ b/src/HttpRequestConnectChain.h @@ -49,13 +49,11 @@ struct HttpRequestConnectChain : public ControlChain { virtual ~HttpRequestConnectChain() {} virtual int run(ConnectCommand* t, DownloadEngine* e) CXX11_OVERRIDE { - std::shared_ptr socketRecvBuffer( - new SocketRecvBuffer(t->getSocket())); - std::shared_ptr httpConnection( - new HttpConnection(t->getCuid(), t->getSocket(), socketRecvBuffer)); + auto b = std::make_shared(t->getSocket()); + auto k = std::make_shared(t->getCuid(), t->getSocket(), b); auto c = make_unique( t->getCuid(), t->getRequest(), t->getFileEntry(), t->getRequestGroup(), - httpConnection, e, t->getSocket()); + k, e, t->getSocket()); c->setProxyRequest(t->getProxyRequest()); c->setStatus(Command::STATUS_ONESHOT_REALTIME); e->setNoWait(true); diff --git a/src/PortEventPoll.cc b/src/PortEventPoll.cc index e2b13832..ecd7fbfa 100644 --- a/src/PortEventPoll.cc +++ b/src/PortEventPoll.cc @@ -168,7 +168,7 @@ int translateEvents(EventPoll::EventType events) bool PortEventPoll::addEvents(sock_t socket, const PortEventPoll::KEvent& event) { - std::shared_ptr socketEntry(new KSocketEntry(socket)); + auto socketEntry = std::make_shared(socket); KSocketEntrySet::iterator i = socketEntries_.lower_bound(socketEntry); int r = 0; int errNum = 0; @@ -220,7 +220,7 @@ bool PortEventPoll::addEvents(sock_t socket, Command* command, int events, bool PortEventPoll::deleteEvents(sock_t socket, const PortEventPoll::KEvent& event) { - std::shared_ptr socketEntry(new KSocketEntry(socket)); + auto socketEntry = std::make_shared(socket); KSocketEntrySet::iterator i = socketEntries_.find(socketEntry); if (i == socketEntries_.end()) { A2_LOG_DEBUG(fmt("Socket %d is not found in SocketEntries.", socket)); @@ -271,8 +271,7 @@ bool PortEventPoll::deleteEvents(sock_t socket, Command* command, bool PortEventPoll::addNameResolver( const std::shared_ptr& resolver, Command* command) { - std::shared_ptr entry( - new KAsyncNameResolverEntry(resolver, command)); + auto entry = std::make_shared(resolver, command); KAsyncNameResolverEntrySet::iterator itr = nameResolverEntries_.find(entry); if (itr == nameResolverEntries_.end()) { nameResolverEntries_.insert(entry); @@ -287,8 +286,7 @@ bool PortEventPoll::addNameResolver( bool PortEventPoll::deleteNameResolver( const std::shared_ptr& resolver, Command* command) { - std::shared_ptr entry( - new KAsyncNameResolverEntry(resolver, command)); + auto entry = std::make_shared(resolver, command); KAsyncNameResolverEntrySet::iterator itr = nameResolverEntries_.find(entry); if (itr == nameResolverEntries_.end()) { return false; diff --git a/src/WebSocketResponseCommand.cc b/src/WebSocketResponseCommand.cc index a06c9a01..1fe92ee2 100644 --- a/src/WebSocketResponseCommand.cc +++ b/src/WebSocketResponseCommand.cc @@ -55,8 +55,8 @@ WebSocketResponseCommand::~WebSocketResponseCommand() = default; void WebSocketResponseCommand::afterSend( const std::shared_ptr& httpServer, DownloadEngine* e) { - std::shared_ptr wsSession( - new WebSocketSession(httpServer->getSocket(), getDownloadEngine())); + auto wsSession = std::make_shared( + httpServer->getSocket(), getDownloadEngine()); auto command = make_unique( getCuid(), wsSession, e, wsSession->getSocket()); wsSession->setCommand(command.get());