Skip to content

Commit 860e912

Browse files
Use unique_ptr for pwalletMain (CWallet)
1 parent 99ec126 commit 860e912

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/wallet/test/wallet_test_fixture.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "wallet/db.h"
99
#include "wallet/wallet.h"
1010

11-
CWallet *pwalletMain;
11+
std::unique_ptr<CWallet> pwalletMain;
1212

1313
WalletTestingSetup::WalletTestingSetup(const std::string& chainName):
1414
TestingSetup(chainName)
@@ -17,18 +17,17 @@ WalletTestingSetup::WalletTestingSetup(const std::string& chainName):
1717

1818
bool fFirstRun;
1919
std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, "wallet_test.dat"));
20-
pwalletMain = new CWallet(std::move(dbw));
20+
pwalletMain = std::unique_ptr<CWallet>(new CWallet(std::move(dbw)));
2121
pwalletMain->LoadWallet(fFirstRun);
22-
RegisterValidationInterface(pwalletMain);
22+
RegisterValidationInterface(pwalletMain.get());
2323

2424
RegisterWalletRPCCommands(tableRPC);
2525
}
2626

2727
WalletTestingSetup::~WalletTestingSetup()
2828
{
29-
UnregisterValidationInterface(pwalletMain);
30-
delete pwalletMain;
31-
pwalletMain = nullptr;
29+
UnregisterValidationInterface(pwalletMain.get());
30+
pwalletMain.reset();
3231

3332
bitdb.Flush(true);
3433
bitdb.Reset();

0 commit comments

Comments
 (0)