src: Removing unnecessary use of cref() in concert with make_shared
This commit also replaces all usages of shared_ptr<T>(new T) with
make_shared<T> in Face class implementation.
Change-Id: I44971c44eb7f2c25ecfe00e185309973c9cbd246
Refs: #1592
diff --git a/src/face.cpp b/src/face.cpp
index ee35f28..6432acf 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -32,7 +32,7 @@
, m_isDirectNfdFibManagementRequested(false)
{
const std::string socketName = UnixTransport::getDefaultSocketName(m_config);
- construct(shared_ptr<Transport>(new UnixTransport(socketName)),
+ construct(make_shared<UnixTransport>(socketName),
make_shared<boost::asio::io_service>());
}
@@ -41,7 +41,7 @@
, m_isDirectNfdFibManagementRequested(false)
{
const std::string socketName = UnixTransport::getDefaultSocketName(m_config);
- construct(shared_ptr<Transport>(new UnixTransport(socketName)),
+ construct(make_shared<UnixTransport>(socketName),
ioService);
}
@@ -59,14 +59,14 @@
, m_isDirectNfdFibManagementRequested(false)
{
const std::string socketName = UnixTransport::getDefaultSocketName(m_config);
- construct(shared_ptr<Transport>(new UnixTransport(socketName)),
+ construct(make_shared<UnixTransport>(socketName),
shared_ptr<boost::asio::io_service>(&ioService, NullIoDeleter()));
}
Face::Face(const std::string& host, const std::string& port/* = "6363"*/)
: m_nfdController(new nfd::Controller(*this))
{
- construct(shared_ptr<Transport>(new TcpTransport(host, port)),
+ construct(make_shared<TcpTransport>(host, port),
make_shared<boost::asio::io_service>());
}
@@ -139,7 +139,7 @@
m_transport->connect(*m_ioService,
bind(&Face::onReceiveElement, this, _1));
- shared_ptr<Interest> interestToExpress(new Interest(interest));
+ shared_ptr<Interest> interestToExpress = make_shared<Interest>(interest);
// If the same ioService thread, dispatch directly calls the method
m_ioService->dispatch(bind(&Face::asyncExpressInterest, this,
@@ -171,8 +171,7 @@
if (!m_transport->isExpectingData())
m_transport->resume();
- m_pendingInterestTable.push_back(shared_ptr<PendingInterest>(new PendingInterest
- (interest, onData, onTimeout)));
+ m_pendingInterestTable.push_back(make_shared<PendingInterest>(interest, onData, onTimeout));
if (!interest->getLocalControlHeader().empty(false, true))
{
@@ -574,7 +573,7 @@
if (block.type() == Tlv::Interest)
{
- shared_ptr<Interest> interest(new Interest());
+ shared_ptr<Interest> interest = make_shared<Interest>();
interest->wireDecode(block);
if (&block != &blockFromDaemon)
interest->getLocalControlHeader().wireDecode(blockFromDaemon);
@@ -583,7 +582,7 @@
}
else if (block.type() == Tlv::Data)
{
- shared_ptr<Data> data(new Data());
+ shared_ptr<Data> data = make_shared<Data>();
data->wireDecode(block);
if (&block != &blockFromDaemon)
data->getLocalControlHeader().wireDecode(blockFromDaemon);