Skip to content

Commit 4366be2

Browse files
committed
Merge bitcoin#2467: [Refactor] Replace MakeUnique with std::make_unique (C++14)
68a36a3 [Cleanup] Remove no longer needed util/memory.h (random-zebra) 24b0f73 scripted-diff: replace MakeUnique with std::make_unique (random-zebra) Pull request description: Also remove `util/memory.h` and relative header includes. As suggested by @Fuzzbawls in PIVX-Project#2462 (review). Based on top of - [x] bitcoin#2462 ACKs for top commit: furszy: utACK 68a36a3 Fuzzbawls: ACK 68a36a3 Tree-SHA512: 4dffacd07ffa24918a91f141e03838c6deb8e448f3cff0dfe0adbbb014e10568ff58bc0828ba8950d05ef4908a4d860f8755d1fa12df57192255a429b32bd605
2 parents 60d3629 + 68a36a3 commit 4366be2

File tree

17 files changed

+17
-47
lines changed

17 files changed

+17
-47
lines changed

src/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ BITCOIN_CORE_H = \
286286
uint256.h \
287287
undo.h \
288288
util/blockstatecatcher.h \
289-
util/memory.h \
290289
util/system.h \
291290
util/macros.h \
292291
util/string.h \

src/httprpc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "rpc/server.h"
1515
#include "random.h"
1616
#include "sync.h"
17-
#include "util/memory.h"
1817
#include "util/system.h"
1918
#include "utilstrencodings.h"
2019

@@ -234,7 +233,7 @@ bool StartHTTPRPC()
234233
RegisterHTTPHandler("/wallet/", false, HTTPReq_JSONRPC);
235234
#endif
236235
assert(EventBase());
237-
httpRPCTimerInterface = MakeUnique<HTTPRPCTimerInterface>(EventBase());
236+
httpRPCTimerInterface = std::make_unique<HTTPRPCTimerInterface>(EventBase());
238237
RPCSetTimerInterface(httpRPCTimerInterface.get());
239238
return true;
240239
}

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ bool AppInitMain()
13441344
// need to reindex later.
13451345

13461346
assert(!g_connman);
1347-
g_connman = MakeUnique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()));
1347+
g_connman = std::make_unique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()));
13481348
CConnman& connman = *g_connman;
13491349

13501350
peerLogic.reset(new PeerLogicValidation(&connman));

src/interfaces/handler.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
#include <interfaces/handler.h>
77

8-
#include <util/memory.h>
9-
108
#include <boost/signals2/connection.hpp>
119
#include <utility>
1210

@@ -27,7 +25,7 @@ class HandlerImpl : public Handler
2725

2826
std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection)
2927
{
30-
return MakeUnique<HandlerImpl>(std::move(connection));
28+
return std::make_unique<HandlerImpl>(std::move(connection));
3129
}
3230

3331
} // namespace interfaces

src/net.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "netmessagemaker.h"
2121
#include "primitives/transaction.h"
2222
#include "scheduler.h"
23-
#include "util/memory.h"
2423
#include "validation.h"
2524

2625
#ifdef WIN32
@@ -1983,7 +1982,7 @@ bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options c
19831982

19841983
if (semOutbound == nullptr) {
19851984
// initialize semaphore
1986-
semOutbound = MakeUnique<CSemaphore>(std::min((nMaxOutbound + nMaxFeeler), nMaxConnections));
1985+
semOutbound = std::make_unique<CSemaphore>(std::min((nMaxOutbound + nMaxFeeler), nMaxConnections));
19871986
}
19881987

19891988
if (pnodeLocalHost == nullptr) {
@@ -2330,7 +2329,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
23302329
nNextLocalAddrSend = 0;
23312330
nNextAddrSend = 0;
23322331
fRelayTxes = false;
2333-
pfilter = MakeUnique<CBloomFilter>();
2332+
pfilter = std::make_unique<CBloomFilter>();
23342333
timeLastMempoolReq = 0;
23352334
nPingNonceSent = 0;
23362335
nPingUsecStart = 0;

src/qt/pivx/masternodeswidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ void MasterNodesWidget::onStartAllClicked(int type)
259259
if (isLoading) {
260260
inform(tr("Background task is being executed, please wait"));
261261
} else {
262-
std::unique_ptr<WalletModel::UnlockContext> pctx = MakeUnique<WalletModel::UnlockContext>(walletModel->requestUnlock());
262+
std::unique_ptr<WalletModel::UnlockContext> pctx = std::make_unique<WalletModel::UnlockContext>(walletModel->requestUnlock());
263263
if (!pctx->isValid()) {
264264
warn(tr("Start ALL masternodes failed"), tr("Wallet unlock cancelled"));
265265
return;

src/qt/pivx/send.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void SendWidget::ProcessSend(QList<SendCoinsRecipient>& recipients, bool hasShie
421421
}
422422
}
423423

424-
auto ptrUnlockedContext = MakeUnique<WalletModel::UnlockContext>(walletModel->requestUnlock());
424+
auto ptrUnlockedContext = std::make_unique<WalletModel::UnlockContext>(walletModel->requestUnlock());
425425
if (!ptrUnlockedContext->isValid()) {
426426
// Unlock wallet was cancelled
427427
inform(tr("Cannot send, wallet locked"));

src/qt/pivx/topbar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ void TopBar::showUpgradeDialog(const QString& message)
544544
{
545545
QString title = tr("Wallet Upgrade");
546546
if (ask(title, message)) {
547-
std::unique_ptr<WalletModel::UnlockContext> pctx = MakeUnique<WalletModel::UnlockContext>(walletModel->requestUnlock());
547+
std::unique_ptr<WalletModel::UnlockContext> pctx = std::make_unique<WalletModel::UnlockContext>(walletModel->requestUnlock());
548548
if (!pctx->isValid()) {
549549
warn(tr("Upgrade Wallet"), tr("Wallet unlock cancelled"));
550550
return;

src/rpc/mining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ UniValue generate(const JSONRPCRequest& request)
123123
EnsureWalletIsUnlocked(pwallet);
124124
} else {
125125
// Coinbase key
126-
reservekey = MakeUnique<CReserveKey>(pwallet);
126+
reservekey = std::make_unique<CReserveKey>(pwallet);
127127
CPubKey pubkey;
128128
if (!reservekey->GetReservedKey(pubkey)) throw JSONRPCError(RPC_INTERNAL_ERROR, "Error: Cannot get key from keypool");
129129
coinbaseScript = GetScriptForDestination(pubkey.GetID());

src/test/fuzz/fuzz.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "chainparams.h"
1010
#include "pubkey.h"
11-
#include "util/memory.h"
1211

1312

1413
static bool read_stdin(std::vector<uint8_t>& data)
@@ -25,7 +24,7 @@ static bool read_stdin(std::vector<uint8_t>& data)
2524

2625
static void initialize()
2726
{
28-
const static auto verify_handle = MakeUnique<ECCVerifyHandle>();
27+
const static auto verify_handle = std::make_unique<ECCVerifyHandle>();
2928
SelectParams(CBaseChainParams::MAIN);
3029
}
3130

0 commit comments

Comments
 (0)