mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Use make_unique instead of using new (#4502)
Signed-off-by: pasta <pasta@dashboost.org>
This commit is contained in:
parent
89e0ccc3dd
commit
e2d12d184e
@ -1160,13 +1160,13 @@ const CChainParams &Params() {
|
||||
std::unique_ptr<const CChainParams> CreateChainParams(const std::string& chain)
|
||||
{
|
||||
if (chain == CBaseChainParams::MAIN)
|
||||
return std::unique_ptr<CChainParams>(new CMainParams());
|
||||
return std::make_unique<CMainParams>();
|
||||
else if (chain == CBaseChainParams::TESTNET)
|
||||
return std::unique_ptr<CChainParams>(new CTestNetParams());
|
||||
return std::make_unique<CTestNetParams>();
|
||||
else if (chain == CBaseChainParams::DEVNET) {
|
||||
return std::unique_ptr<CChainParams>(new CDevNetParams(gArgs));
|
||||
return std::make_unique<CDevNetParams>(gArgs);
|
||||
} else if (chain == CBaseChainParams::REGTEST)
|
||||
return std::unique_ptr<CChainParams>(new CRegTestParams(gArgs));
|
||||
return std::make_unique<CRegTestParams>(gArgs);
|
||||
|
||||
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ CScript CKeyHolder::GetScriptForDestination() const
|
||||
|
||||
CScript CKeyHolderStorage::AddKey(CWallet* pwallet)
|
||||
{
|
||||
auto keyHolderPtr = std::unique_ptr<CKeyHolder>(new CKeyHolder(pwallet));
|
||||
auto keyHolderPtr = std::make_unique<CKeyHolder>(pwallet);
|
||||
auto script = keyHolderPtr->GetScriptForDestination();
|
||||
|
||||
LOCK(cs_storage);
|
||||
|
@ -226,7 +226,7 @@ static void http_request_cb(struct evhttp_request* req, void* arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
std::unique_ptr<HTTPRequest> hreq(new HTTPRequest(req));
|
||||
auto hreq{std::make_unique<HTTPRequest>(req)};
|
||||
|
||||
// Early address-based allow check
|
||||
if (!ClientAllowed(hreq->GetPeer())) {
|
||||
@ -266,7 +266,7 @@ static void http_request_cb(struct evhttp_request* req, void* arg)
|
||||
|
||||
// Dispatch to worker thread
|
||||
if (i != iend) {
|
||||
std::unique_ptr<HTTPWorkItem> item(new HTTPWorkItem(std::move(hreq), path, i->handler));
|
||||
auto item{std::make_unique<HTTPWorkItem>(std::move(hreq), path, i->handler)};
|
||||
assert(g_work_queue);
|
||||
if (g_work_queue->Enqueue(item.get())) {
|
||||
item.release(); /* if true, queue took ownership */
|
||||
|
@ -1782,7 +1782,7 @@ bool AppInitMain()
|
||||
assert(!g_banman);
|
||||
g_banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", &uiInterface, gArgs.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
|
||||
assert(!g_connman);
|
||||
g_connman = std::unique_ptr<CConnman>(new CConnman(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max())));
|
||||
g_connman = std::make_unique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()));
|
||||
|
||||
peerLogic.reset(new PeerLogicValidation(g_connman.get(), g_banman.get(), scheduler, gArgs.GetBoolArg("-enablebip61", DEFAULT_ENABLE_BIP61)));
|
||||
RegisterValidationInterface(peerLogic.get());
|
||||
|
@ -537,9 +537,9 @@ CBlockPolicyEstimator::CBlockPolicyEstimator()
|
||||
bucketMap[INF_FEERATE] = bucketIndex;
|
||||
assert(bucketMap.size() == buckets.size());
|
||||
|
||||
feeStats = std::unique_ptr<TxConfirmStats>(new TxConfirmStats(buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE));
|
||||
shortStats = std::unique_ptr<TxConfirmStats>(new TxConfirmStats(buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE));
|
||||
longStats = std::unique_ptr<TxConfirmStats>(new TxConfirmStats(buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE));
|
||||
feeStats = std::make_unique<TxConfirmStats>(buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE);
|
||||
shortStats = std::make_unique<TxConfirmStats>(buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE);
|
||||
longStats = std::make_unique<TxConfirmStats>(buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE);
|
||||
}
|
||||
|
||||
CBlockPolicyEstimator::~CBlockPolicyEstimator()
|
||||
@ -949,9 +949,9 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein)
|
||||
if (numBuckets <= 1 || numBuckets > 1000)
|
||||
throw std::runtime_error("Corrupt estimates file. Must have between 2 and 1000 feerate buckets");
|
||||
|
||||
std::unique_ptr<TxConfirmStats> fileFeeStats(new TxConfirmStats(buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE));
|
||||
std::unique_ptr<TxConfirmStats> fileShortStats(new TxConfirmStats(buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE));
|
||||
std::unique_ptr<TxConfirmStats> fileLongStats(new TxConfirmStats(buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE));
|
||||
auto fileFeeStats{std::make_unique<TxConfirmStats>(buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE)};
|
||||
auto fileShortStats{std::make_unique<TxConfirmStats>(buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE)};
|
||||
auto fileLongStats{std::make_unique<TxConfirmStats>(buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE)};
|
||||
fileFeeStats->Read(filein, nVersionThatWrote, numBuckets);
|
||||
fileShortStats->Read(filein, nVersionThatWrote, numBuckets);
|
||||
fileLongStats->Read(filein, nVersionThatWrote, numBuckets);
|
||||
|
@ -408,9 +408,9 @@ void LockedPoolManager::CreateInstance()
|
||||
// have a static deinitialization order/problem, but the check in
|
||||
// LockedPoolManagerBase's destructor helps us detect if that ever happens.
|
||||
#ifdef WIN32
|
||||
std::unique_ptr<LockedPageAllocator> allocator(new Win32LockedPageAllocator());
|
||||
std::unique_ptr<LockedPageAllocator> allocator{std::make_unique<Win32LockedPageAllocator>()};
|
||||
#else
|
||||
std::unique_ptr<LockedPageAllocator> allocator(new PosixLockedPageAllocator());
|
||||
std::unique_ptr<LockedPageAllocator> allocator{std::make_unique<PosixLockedPageAllocator>()};
|
||||
#endif
|
||||
static LockedPoolManager instance(std::move(allocator));
|
||||
LockedPoolManager::_instance = &instance;
|
||||
|
Loading…
Reference in New Issue
Block a user