Skip to content

Commit a3346e2

Browse files
committed
scripted-diff: Use C++11 nullptr instead of NULL
-BEGIN VERIFY SCRIPT- sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/qt/pivx/*/*.cpp src/qt/pivx/*/*.h src/wallet/*/*.cpp src/test/*/*.cpp src/wallet/*/*.h sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp -END VERIFY SCRIPT-
1 parent a51b254 commit a3346e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+443
-443
lines changed

src/activemasternode.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ bool CActiveMasternode::SendMasternodePing(std::string& errorMessage)
183183

184184
// Update lastPing for our masternode in Masternode list
185185
CMasternode* pmn = mnodeman.Find(vin->prevout);
186-
if (pmn != NULL) {
186+
if (pmn != nullptr) {
187187
if (pmn->IsPingedWithin(MasternodePingSeconds(), mnp.sigTime)) {
188188
errorMessage = "Too early to send Masternode Ping";
189189
return false;

src/addrman.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ CAddrInfo* CAddrMan::Find(const CNetAddr& addr, int* pnId)
7171
{
7272
std::map<CNetAddr, int>::iterator it = mapAddr.find(addr);
7373
if (it == mapAddr.end())
74-
return NULL;
74+
return nullptr;
7575
if (pnId)
7676
*pnId = (*it).second;
7777
std::map<int, CAddrInfo>::iterator it2 = mapInfo.find((*it).second);
7878
if (it2 != mapInfo.end())
7979
return &(*it2).second;
80-
return NULL;
80+
return nullptr;
8181
}
8282

8383
CAddrInfo* CAddrMan::Create(const CAddress& addr, const CNetAddr& addrSource, int* pnId)

src/addrman.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ class CAddrMan
229229
FastRandomContext insecure_rand;
230230

231231
//! Find an entry.
232-
CAddrInfo* Find(const CNetAddr& addr, int* pnId = NULL);
232+
CAddrInfo* Find(const CNetAddr& addr, int* pnId = nullptr);
233233

234234
//! find an entry, creating it if necessary.
235235
//! nTime and nServices of the found node are updated, if necessary.
236-
CAddrInfo* Create(const CAddress& addr, const CNetAddr& addrSource, int* pnId = NULL);
236+
CAddrInfo* Create(const CAddress& addr, const CNetAddr& addrSource, int* pnId = nullptr);
237237

238238
//! Swap two elements in vRandom.
239239
void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2);

src/allocators.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <unistd.h> // for sysconf
2525
#endif
2626

27-
LockedPageManager* LockedPageManager::_instance = NULL;
27+
LockedPageManager* LockedPageManager::_instance = nullptr;
2828
boost::once_flag LockedPageManager::init_flag = BOOST_ONCE_INIT;
2929

3030
/** Determine system page size in bytes */

src/allocators.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ struct secure_allocator : public std::allocator<T> {
191191
{
192192
T* p;
193193
p = std::allocator<T>::allocate(n, hint);
194-
if (p != NULL)
194+
if (p != nullptr)
195195
LockedPageManager::Instance().LockRange(p, sizeof(T) * n);
196196
return p;
197197
}
198198

199199
void deallocate(T* p, std::size_t n)
200200
{
201-
if (p != NULL) {
201+
if (p != nullptr) {
202202
memory_cleanse(p, sizeof(T) * n);
203203
LockedPageManager::Instance().UnlockRange(p, sizeof(T) * n);
204204
}
@@ -235,7 +235,7 @@ struct zero_after_free_allocator : public std::allocator<T> {
235235

236236
void deallocate(T* p, std::size_t n)
237237
{
238-
if (p != NULL)
238+
if (p != nullptr)
239239
memory_cleanse(p, sizeof(T) * n);
240240
std::allocator<T>::deallocate(p, n);
241241
}

src/arith_uint256.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ class arith_uint256 : public base_uint<256> {
360360
* complexities of the sign bit and using base 256 are probably an
361361
* implementation accident.
362362
*/
363-
arith_uint256& SetCompact(uint32_t nCompact, bool *pfNegative = NULL, bool *pfOverflow = NULL);
363+
arith_uint256& SetCompact(uint32_t nCompact, bool *pfNegative = nullptr, bool *pfOverflow = nullptr);
364364
uint32_t GetCompact(bool fNegative = false) const;
365365
uint32_t Get32(int n = 0) const { return pn[2 * n]; }
366366
};

src/base58.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch)
3939
while (*psz && !isspace(*psz)) {
4040
// Decode base58 character
4141
const char* ch = strchr(pszBase58, *psz);
42-
if (ch == NULL)
42+
if (ch == nullptr)
4343
return false;
4444
// Apply "b256 = b256 * 58 + ch".
4545
int carry = ch - pszBase58;

src/base58.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
/**
2727
* Encode a byte sequence as a base58-encoded string.
28-
* pbegin and pend cannot be NULL, unless both are.
28+
* pbegin and pend cannot be nullptr, unless both are.
2929
*/
3030
std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend);
3131

@@ -37,13 +37,13 @@ std::string EncodeBase58(const std::vector<unsigned char>& vch);
3737
/**
3838
* Decode a base58-encoded string (psz) into a byte vector (vchRet).
3939
* return true if decoding is successful.
40-
* psz cannot be NULL.
40+
* psz cannot be nullptr.
4141
*/
4242
bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet);
4343

4444
/**
4545
* Decode a base58-encoded string (psz) into a string.
46-
* psz cannot be NULL.
46+
* psz cannot be nullptr.
4747
*/
4848
std::string DecodeBase58(const char* psz);
4949

src/budget/budgetmanager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ void CBudgetManager::VoteOnFinalizedBudgets()
511511
continue;
512512
}
513513
std::string strError = "";
514-
if (!UpdateFinalizedBudget(vote, NULL, strError)) {
514+
if (!UpdateFinalizedBudget(vote, nullptr, strError)) {
515515
LogPrintf("%s: Error submitting vote - %s\n", __func__, strError);
516516
continue;
517517
}
@@ -528,7 +528,7 @@ CFinalizedBudget* CBudgetManager::FindFinalizedBudget(const uint256& nHash)
528528
if (mapFinalizedBudgets.count(nHash))
529529
return &mapFinalizedBudgets[nHash];
530530

531-
return NULL;
531+
return nullptr;
532532
}
533533

534534
const CBudgetProposal* CBudgetManager::FindProposalByName(const std::string& strProposalName) const

src/chain.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
void CChain::SetTip(CBlockIndex* pindex)
1515
{
16-
if (pindex == NULL) {
16+
if (pindex == nullptr) {
1717
vChain.clear();
1818
return;
1919
}
@@ -81,7 +81,7 @@ int static inline GetSkipHeight(int height)
8181
CBlockIndex* CBlockIndex::GetAncestor(int height)
8282
{
8383
if (height > nHeight || height < 0)
84-
return NULL;
84+
return nullptr;
8585

8686
CBlockIndex* pindexWalk = this;
8787
int heightWalk = nHeight;
@@ -327,7 +327,7 @@ bool CBlockIndex::RaiseValidity(enum BlockStatus nUpTo)
327327
}
328328

329329
/** Find the last common ancestor two blocks have.
330-
* Both pa and pb must be non-NULL. */
330+
* Both pa and pb must be non-nullptr. */
331331
const CBlockIndex* LastCommonAncestor(const CBlockIndex* pa, const CBlockIndex* pb)
332332
{
333333
if (pa->nHeight > pb->nHeight) {

src/chain.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -530,17 +530,17 @@ class CChain
530530
std::vector<CBlockIndex*> vChain;
531531

532532
public:
533-
/** Returns the index entry for the genesis block of this chain, or NULL if none. */
533+
/** Returns the index entry for the genesis block of this chain, or nullptr if none. */
534534
CBlockIndex* Genesis() const
535535
{
536-
return vChain.size() > 0 ? vChain[0] : NULL;
536+
return vChain.size() > 0 ? vChain[0] : nullptr;
537537
}
538538

539-
/** Returns the index entry for the tip of this chain, or NULL if none. */
539+
/** Returns the index entry for the tip of this chain, or nullptr if none. */
540540
CBlockIndex* Tip(bool fProofOfStake = false) const
541541
{
542542
if (vChain.size() < 1)
543-
return NULL;
543+
return nullptr;
544544

545545
CBlockIndex* pindex = vChain[vChain.size() - 1];
546546

@@ -551,11 +551,11 @@ class CChain
551551
return pindex;
552552
}
553553

554-
/** Returns the index entry at a particular height in this chain, or NULL if no such height exists. */
554+
/** Returns the index entry at a particular height in this chain, or nullptr if no such height exists. */
555555
CBlockIndex* operator[](int nHeight) const
556556
{
557557
if (nHeight < 0 || nHeight >= (int)vChain.size())
558-
return NULL;
558+
return nullptr;
559559
return vChain[nHeight];
560560
}
561561

@@ -572,13 +572,13 @@ class CChain
572572
return (*this)[pindex->nHeight] == pindex;
573573
}
574574

575-
/** Find the successor of a block in this chain, or NULL if the given index is not found or is the tip. */
575+
/** Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip. */
576576
CBlockIndex* Next(const CBlockIndex* pindex) const
577577
{
578578
if (Contains(pindex))
579579
return (*this)[pindex->nHeight + 1];
580580
else
581-
return NULL;
581+
return nullptr;
582582
}
583583

584584
/** Return the maximal height in the chain. Is equal to chain.Tip() ? chain.Tip()->nHeight : -1. */
@@ -591,7 +591,7 @@ class CChain
591591
void SetTip(CBlockIndex* pindex);
592592

593593
/** Return a CBlockLocator that refers to a block in this chain (by default the tip). */
594-
CBlockLocator GetLocator(const CBlockIndex* pindex = NULL) const;
594+
CBlockLocator GetLocator(const CBlockIndex* pindex = nullptr) const;
595595

596596
/** Find the last common block between this chain and a block index entry. */
597597
const CBlockIndex* FindFork(const CBlockIndex* pindex) const;

src/checkpoints.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ bool CheckBlock(int nHeight, const uint256& hash, bool fMatchesCheckpoint)
4444
//! Guess how far we are in the verification process at the given block index
4545
double GuessVerificationProgress(const CBlockIndex* pindex, bool fSigchecks)
4646
{
47-
if (pindex == NULL)
47+
if (pindex == nullptr)
4848
return 0.0;
4949

50-
int64_t nNow = time(NULL);
50+
int64_t nNow = time(nullptr);
5151

5252
double fSigcheckVerificationFactor = fSigchecks ? SIGCHECK_VERIFICATION_FACTOR : 1.0;
5353
double fWorkBefore = 0.0; // Amount of work done before pindex
@@ -87,7 +87,7 @@ int GetTotalBlocksEstimate()
8787
CBlockIndex* GetLastCheckpoint()
8888
{
8989
if (!fEnabled)
90-
return NULL;
90+
return nullptr;
9191

9292
const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
9393

@@ -97,7 +97,7 @@ CBlockIndex* GetLastCheckpoint()
9797
if (t != mapBlockIndex.end())
9898
return t->second;
9999
}
100-
return NULL;
100+
return nullptr;
101101
}
102102

103103
} // namespace Checkpoints

src/checkqueue.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,16 @@ class CCheckQueueControl
180180
public:
181181
CCheckQueueControl(CCheckQueue<T>* pqueueIn) : pqueue(pqueueIn), fDone(false)
182182
{
183-
// passed queue is supposed to be unused, or NULL
184-
if (pqueue != NULL) {
183+
// passed queue is supposed to be unused, or nullptr
184+
if (pqueue != nullptr) {
185185
bool isIdle = pqueue->IsIdle();
186186
assert(isIdle);
187187
}
188188
}
189189

190190
bool Wait()
191191
{
192-
if (pqueue == NULL)
192+
if (pqueue == nullptr)
193193
return true;
194194
bool fRet = pqueue->Wait();
195195
fDone = true;
@@ -198,7 +198,7 @@ class CCheckQueueControl
198198

199199
void Add(std::vector<T>& vChecks)
200200
{
201-
if (pqueue != NULL)
201+
if (pqueue != nullptr)
202202
pqueue->Add(vChecks);
203203
}
204204

src/consensus/merkle.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
128128

129129
uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated) {
130130
uint256 hash;
131-
MerkleComputation(leaves, &hash, mutated, -1, NULL);
131+
MerkleComputation(leaves, &hash, mutated, -1, nullptr);
132132
return hash;
133133
}
134134

135135
std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position) {
136136
std::vector<uint256> ret;
137-
MerkleComputation(leaves, NULL, NULL, position, &ret);
137+
MerkleComputation(leaves, nullptr, nullptr, position, &ret);
138138
return ret;
139139
}
140140

src/consensus/merkle.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
#include "primitives/block.h"
1313
#include "uint256.h"
1414

15-
uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated = NULL);
15+
uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated = nullptr);
1616
std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position);
1717
uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vector<uint256>& branch, uint32_t position);
1818

1919
/*
2020
* Compute the Merkle root of the transactions in a block.
2121
* *mutated is set to true if a duplicated subtree was found.
2222
*/
23-
uint256 BlockMerkleRoot(const CBlock& block, bool* mutated = NULL);
23+
uint256 BlockMerkleRoot(const CBlock& block, bool* mutated = nullptr);
2424

2525
/*
2626
* Compute the Merkle branch for the tree of transactions in a block, for a

src/core_write.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco
9393
// this won't decode correctly formatted public keys in Pubkey or Multisig scripts due to
9494
// the restrictions on the pubkey formats (see IsCompressedOrUncompressedPubKey) being incongruous with the
9595
// checks in CheckSignatureEncoding.
96-
if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, NULL)) {
96+
if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, nullptr)) {
9797
const unsigned char chSigHashType = vch.back();
9898
if (mapSigHashTypes.count(chSigHashType)) {
9999
strSigHashDecode = "[" + mapSigHashTypes.find(chSigHashType)->second + "]";

src/dbwrapper.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static leveldb::Options GetOptions(size_t nCacheSize)
3131

3232
CDBWrapper::CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory, bool fWipe)
3333
{
34-
penv = NULL;
34+
penv = nullptr;
3535
readoptions.verify_checksums = true;
3636
iteroptions.verify_checksums = true;
3737
iteroptions.fill_cache = false;
@@ -58,13 +58,13 @@ CDBWrapper::CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory, bo
5858
CDBWrapper::~CDBWrapper()
5959
{
6060
delete pdb;
61-
pdb = NULL;
61+
pdb = nullptr;
6262
delete options.filter_policy;
63-
options.filter_policy = NULL;
63+
options.filter_policy = nullptr;
6464
delete options.block_cache;
65-
options.block_cache = NULL;
65+
options.block_cache = nullptr;
6666
delete penv;
67-
options.env = NULL;
67+
options.env = nullptr;
6868
}
6969

7070
bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync)

src/dbwrapper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class CDBIterator
175175
class CDBWrapper
176176
{
177177
private:
178-
//! custom environment this database is using (may be NULL in case of default environment)
178+
//! custom environment this database is using (may be nullptr in case of default environment)
179179
leveldb::Env* penv;
180180

181181
//! database options used

src/hash.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ class CBLAKE2bWriter
370370
CBLAKE2bWriter(int nTypeIn, int nVersionIn, const unsigned char* personal) : nType(nTypeIn), nVersion(nVersionIn) {
371371
assert(crypto_generichash_blake2b_init_salt_personal(
372372
&state,
373-
NULL, 0, // No key.
373+
nullptr, 0, // No key.
374374
32,
375-
NULL, // No salt.
375+
nullptr, // No salt.
376376
personal) == 0);
377377
}
378378

0 commit comments

Comments
 (0)