From a4e806fcb9ef8b793814b4784fa92b6e1b0336ee Mon Sep 17 00:00:00 2001 From: practicalswift Date: Tue, 15 Aug 2017 07:46:56 +0200 Subject: [PATCH] Use MakeUnique(...) instead of std::unique_ptr(new T(...)) --- src/httprpc.cpp | 2 +- src/net.cpp | 6 +++--- src/wallet/db.cpp | 4 ++-- src/wallet/test/wallet_test_fixture.cpp | 2 +- src/wallet/wallet.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 28ce8f87db..bc3cca468d 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -239,7 +239,7 @@ bool StartHTTPRPC() RegisterHTTPHandler("/wallet/", false, HTTPReq_JSONRPC); #endif assert(EventBase()); - httpRPCTimerInterface = std::unique_ptr(new HTTPRPCTimerInterface(EventBase())); + httpRPCTimerInterface = MakeUnique(EventBase()); RPCSetTimerInterface(httpRPCTimerInterface.get()); return true; } diff --git a/src/net.cpp b/src/net.cpp index 47691b0ca5..e76ac1644e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2363,11 +2363,11 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions) if (semOutbound == nullptr) { // initialize semaphore - semOutbound = std::unique_ptr(new CSemaphore(std::min((nMaxOutbound + nMaxFeeler), nMaxConnections))); + semOutbound = MakeUnique(std::min((nMaxOutbound + nMaxFeeler), nMaxConnections)); } if (semAddnode == nullptr) { // initialize semaphore - semAddnode = std::unique_ptr(new CSemaphore(nMaxAddnode)); + semAddnode = MakeUnique(nMaxAddnode); } // @@ -2785,7 +2785,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn nNextInvSend = 0; fRelayTxes = false; fSentAddr = false; - pfilter = std::unique_ptr(new CBloomFilter()); + pfilter = MakeUnique(); timeLastMempoolReq = 0; nLastBlockTime = 0; nLastTXTime = 0; diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 0f5b22716a..9898b12151 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -223,7 +223,7 @@ bool CDB::Recover(const std::string& filename, void *callbackDataIn, bool (*reco } LogPrintf("Salvage(aggressive) found %u records\n", salvagedData.size()); - std::unique_ptr pdbCopy(new Db(bitdb.dbenv.get(), 0)); + std::unique_ptr pdbCopy = MakeUnique(bitdb.dbenv.get(), 0); int ret = pdbCopy->open(nullptr, // Txn pointer filename.c_str(), // Filename "main", // Logical db name @@ -523,7 +523,7 @@ bool CDB::Rewrite(CWalletDBWrapper& dbw, const char* pszSkip) std::string strFileRes = strFile + ".rewrite"; { // surround usage of db with extra {} CDB db(dbw, "r"); - std::unique_ptr pdbCopy = std::unique_ptr(new Db(env->dbenv.get(), 0)); + std::unique_ptr pdbCopy = MakeUnique(env->dbenv.get(), 0); int ret = pdbCopy->open(nullptr, // Txn pointer strFileRes.c_str(), // Filename diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp index 016ce6a9f9..b304861b1d 100644 --- a/src/wallet/test/wallet_test_fixture.cpp +++ b/src/wallet/test/wallet_test_fixture.cpp @@ -18,7 +18,7 @@ WalletTestingSetup::WalletTestingSetup(const std::string &chainName) : bool fFirstRun; std::unique_ptr dbw(new CWalletDBWrapper(&bitdb, "wallet_test.dat")); - pwalletMain = std::unique_ptr(new CWallet(std::move(dbw))); + pwalletMain = MakeUnique(std::move(dbw)); pwalletMain->LoadWallet(fFirstRun); RegisterValidationInterface(pwalletMain.get()); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 350abc2bd1..28992da94a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4672,7 +4672,7 @@ CWallet* CWallet:: CreateWalletFromFile(const std::string walletFile) uiInterface.InitMessage(_("Zapping all transactions from wallet...")); std::unique_ptr dbw(new CWalletDBWrapper(&bitdb, walletFile)); - std::unique_ptr tempWallet(new CWallet(std::move(dbw))); + std::unique_ptr tempWallet = MakeUnique(std::move(dbw)); DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx); if (nZapWalletRet != DB_LOAD_OK) { InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));