mirror of https://github.com/aria2/aria2
Use std::make_shared
parent
2448a8660b
commit
2bbec1086d
|
@ -62,7 +62,7 @@ public:
|
|||
// Receives LPD message and returns LpdMessage which contains
|
||||
// sender(peer) and infohash. If no data is available on socket,
|
||||
// returns std::shared_ptr<LpdMessage>(). If received data is bad,
|
||||
// then returns std::shared_ptr<LpdMessage>(new LpdMessage())
|
||||
// they are just skipped.
|
||||
std::unique_ptr<LpdMessage> receiveMessage();
|
||||
|
||||
const std::shared_ptr<SocketCore>& getSocket() const
|
||||
|
|
|
@ -364,7 +364,7 @@ std::shared_ptr<SocketCore> SocketCore::acceptConnection() const
|
|||
if(fd == (sock_t) -1) {
|
||||
throw DL_ABORT_EX(fmt(EX_SOCKET_ACCEPT, errorMsg(errNum).c_str()));
|
||||
}
|
||||
auto sock = std::shared_ptr<SocketCore>(new SocketCore(fd, sockType_));
|
||||
auto sock = std::make_shared<SocketCore>(fd, sockType_);
|
||||
sock->setNonBlockingMode();
|
||||
return sock;
|
||||
}
|
||||
|
|
|
@ -111,9 +111,13 @@ private:
|
|||
|
||||
void setSockOpt(int level, int optname, void* optval, socklen_t optlen);
|
||||
|
||||
SocketCore(sock_t sockfd, int sockType);
|
||||
public:
|
||||
SocketCore(int sockType = SOCK_STREAM);
|
||||
|
||||
// Formally, private constructor, but made public to use with
|
||||
// std::make_shared.
|
||||
SocketCore(sock_t sockfd, int sockType);
|
||||
|
||||
~SocketCore();
|
||||
|
||||
sock_t getSockfd() const { return sockfd_; }
|
||||
|
|
|
@ -877,7 +877,7 @@ nextParam
|
|||
template<typename T>
|
||||
std::shared_ptr<T> copy(const std::shared_ptr<T>& a)
|
||||
{
|
||||
return std::shared_ptr<T>(new T(*a.get()));
|
||||
return std::make_shared<T>(*a.get());
|
||||
}
|
||||
|
||||
// This is a bit different from cookie_helper::domainMatch(). If
|
||||
|
|
Loading…
Reference in New Issue