mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 10:35:50 +00:00
Replace calls to new(). (#243)
* Replace all unavoidable uses of `new` with `std::make_unique` or `std::make_shared`. * Fix some 80-column issues.
This commit is contained in:
committed by
Scott Schurr
parent
ef51128270
commit
d5193a776e
@@ -371,7 +371,7 @@ public:
|
||||
|
||||
, m_orderBookDB (*m_jobQueue)
|
||||
|
||||
, m_pathRequests (new PathRequests (
|
||||
, m_pathRequests (std::make_unique<PathRequests> (
|
||||
m_logs.journal("PathRequest"), m_collectorManager->collector ()))
|
||||
|
||||
, m_ledgerMaster (make_LedgerMaster (getConfig (), stopwatch (),
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/app/main/CollectorManager.h>
|
||||
#include <beast/cxx14/memory.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -56,12 +57,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
beast::insight::Collector::ptr const& collector ()
|
||||
beast::insight::Collector::ptr const& collector () override
|
||||
{
|
||||
return m_collector;
|
||||
}
|
||||
|
||||
beast::insight::Group::ptr const& group (std::string const& name)
|
||||
beast::insight::Group::ptr const& group (std::string const& name) override
|
||||
{
|
||||
return m_groups->get (name);
|
||||
}
|
||||
@@ -73,10 +74,10 @@ CollectorManager::~CollectorManager ()
|
||||
{
|
||||
}
|
||||
|
||||
CollectorManager* CollectorManager::New (Section const& params,
|
||||
std::unique_ptr<CollectorManager> CollectorManager::New(Section const& params,
|
||||
beast::Journal journal)
|
||||
{
|
||||
return new CollectorManagerImp (params, journal);
|
||||
return std::make_unique<CollectorManagerImp>(params, journal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,11 +29,13 @@ namespace ripple {
|
||||
class CollectorManager
|
||||
{
|
||||
public:
|
||||
static CollectorManager* New (Section const& params,
|
||||
beast::Journal journal);
|
||||
static std::unique_ptr<CollectorManager> New (
|
||||
Section const& params, beast::Journal journal);
|
||||
|
||||
virtual ~CollectorManager () = 0;
|
||||
virtual beast::insight::Collector::ptr const& collector () = 0;
|
||||
virtual beast::insight::Group::ptr const& group (std::string const& name) = 0;
|
||||
virtual beast::insight::Group::ptr const& group (
|
||||
std::string const& name) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -128,12 +128,14 @@ public:
|
||||
|
||||
virtual ~HashRouter() = default;
|
||||
|
||||
// VFALCO TODO Replace "Supression" terminology with something more semantically meaningful.
|
||||
// VFALCO TODO Replace "Supression" terminology with something more
|
||||
// semantically meaningful.
|
||||
bool addSuppression (uint256 const& index);
|
||||
|
||||
bool addSuppressionPeer (uint256 const& index, PeerShortID peer);
|
||||
|
||||
bool addSuppressionPeer (uint256 const& index, PeerShortID peer, int& flags);
|
||||
bool addSuppressionPeer (uint256 const& index, PeerShortID peer,
|
||||
int& flags);
|
||||
|
||||
bool addSuppressionFlags (uint256 const& index, int flag);
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace ripple {
|
||||
class ResolverAsio : public Resolver
|
||||
{
|
||||
public:
|
||||
static ResolverAsio* New (
|
||||
boost::asio::io_service& io_service,
|
||||
beast::Journal journal);
|
||||
static
|
||||
std::unique_ptr<ResolverAsio> New (
|
||||
boost::asio::io_service&, beast::Journal);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <ripple/basics/ResolverAsio.h>
|
||||
#include <beast/asio/IPAddressConversion.h>
|
||||
#include <beast/asio/placeholders.h>
|
||||
#include <beast/cxx14/memory.h>
|
||||
#include <beast/module/asio/AsyncObject.h>
|
||||
#include <beast/threads/WaitableEvent.h>
|
||||
#include <boost/asio.hpp>
|
||||
@@ -299,11 +300,11 @@ public:
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ResolverAsio *ResolverAsio::New (
|
||||
std::unique_ptr<ResolverAsio> ResolverAsio::New (
|
||||
boost::asio::io_service& io_service,
|
||||
beast::Journal journal)
|
||||
{
|
||||
return new ResolverAsioImpl (io_service, journal);
|
||||
return std::make_unique<ResolverAsioImpl> (io_service, journal);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -257,10 +257,9 @@ public:
|
||||
assert (iter != m_jobData.end ());
|
||||
|
||||
if (iter == m_jobData.end ())
|
||||
return LoadEvent::autoptr ();
|
||||
return {};
|
||||
|
||||
return LoadEvent::autoptr (
|
||||
new LoadEvent (iter-> second.load (), name, true));
|
||||
return std::make_unique<LoadEvent> (iter-> second.load (), name, true);
|
||||
}
|
||||
|
||||
void addLoadEvents (JobType t,
|
||||
|
||||
@@ -167,11 +167,10 @@ public:
|
||||
{
|
||||
WriteLog (lsTRACE, HTTPClient) << "Fetch: " << mDeqSites[0];
|
||||
|
||||
std::shared_ptr <boost::asio::ip::tcp::resolver::query> query (
|
||||
new boost::asio::ip::tcp::resolver::query (
|
||||
auto query = std::make_shared<boost::asio::ip::tcp::resolver::query>(
|
||||
mDeqSites[0],
|
||||
beast::lexicalCast <std::string> (mPort),
|
||||
boost::asio::ip::resolver_query_base::numeric_service));
|
||||
boost::asio::ip::resolver_query_base::numeric_service);
|
||||
mQuery = query;
|
||||
|
||||
mDeadline.expires_from_now (mTimeout, mShutdown);
|
||||
@@ -528,9 +527,8 @@ void HTTPClient::get (
|
||||
std::function<bool (const boost::system::error_code& ecResult, int iStatus,
|
||||
std::string const& strData)> complete)
|
||||
{
|
||||
std::shared_ptr <HTTPClientImp> client (
|
||||
new HTTPClientImp (io_service, port, responseMax));
|
||||
|
||||
auto client = std::make_shared<HTTPClientImp> (
|
||||
io_service, port, responseMax);
|
||||
client->get (bSSL, deqSites, strPath, timeout, complete);
|
||||
}
|
||||
|
||||
@@ -547,9 +545,8 @@ void HTTPClient::get (
|
||||
{
|
||||
std::deque<std::string> deqSites (1, strSite);
|
||||
|
||||
std::shared_ptr <HTTPClientImp> client (
|
||||
new HTTPClientImp (io_service, port, responseMax));
|
||||
|
||||
auto client = std::make_shared<HTTPClientImp> (
|
||||
io_service, port, responseMax);
|
||||
client->get (bSSL, deqSites, strPath, timeout, complete);
|
||||
}
|
||||
|
||||
@@ -566,9 +563,8 @@ void HTTPClient::request (
|
||||
{
|
||||
std::deque<std::string> deqSites (1, strSite);
|
||||
|
||||
std::shared_ptr <HTTPClientImp> client (
|
||||
new HTTPClientImp (io_service, port, responseMax));
|
||||
|
||||
auto client = std::make_shared<HTTPClientImp> (
|
||||
io_service, port, responseMax);
|
||||
client->request (bSSL, deqSites, setRequest, timeout, complete);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,9 @@ public:
|
||||
*/
|
||||
template <typename Function>
|
||||
void post (Function f)
|
||||
{ m_work.emplace_back (new Work <Function> (f)); }
|
||||
{
|
||||
m_work.emplace_back (std::make_unique<Work <Function>>(f));
|
||||
}
|
||||
|
||||
/** Run all pending functions.
|
||||
The functions will be invoked in the order they were queued.
|
||||
|
||||
@@ -105,9 +105,6 @@ public:
|
||||
}
|
||||
|
||||
bool isValueH160 () const;
|
||||
|
||||
private:
|
||||
static STAccount* construct (SerialIter&, SField const&);
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -39,12 +39,6 @@ std::string STAccount::getText () const
|
||||
return toBase58(u);
|
||||
}
|
||||
|
||||
STAccount*
|
||||
STAccount::construct (SerialIter& u, SField const& name)
|
||||
{
|
||||
return new STAccount (name, u.getVLBuffer ());
|
||||
}
|
||||
|
||||
STAccount::STAccount (SField const& n, AccountID const& v)
|
||||
: STBlob (n, v.data (), v.size ())
|
||||
{
|
||||
|
||||
@@ -262,7 +262,7 @@ Env::submit (JTx const& jt)
|
||||
[&](OpenView& view, beast::Journal j)
|
||||
{
|
||||
std::tie(ter, didApply) = ripple::apply(
|
||||
view, *stx, applyFlags(),
|
||||
view, *stx, applyFlags(),
|
||||
directSigVerify, config,
|
||||
beast::Journal{});
|
||||
return didApply;
|
||||
|
||||
Reference in New Issue
Block a user