Skip to content

Commit 36d326e

Browse files
Use nullptr instead of zero (0) as the null pointer constant
1 parent d451d0b commit 36d326e

16 files changed

+41
-41
lines changed

src/bench/lockedpool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ static void BenchLockedPool(benchmark::State& state)
2121

2222
std::vector<void*> addr;
2323
for (int x=0; x<ASIZE; ++x)
24-
addr.push_back(0);
24+
addr.push_back(nullptr);
2525
uint32_t s = 0x12345678;
2626
while (state.KeepRunning()) {
2727
for (int x=0; x<BITER; ++x) {
2828
int idx = s & (addr.size()-1);
2929
if (s & 0x80000000) {
3030
b.free(addr[idx]);
31-
addr[idx] = 0;
31+
addr[idx] = nullptr;
3232
} else if(!addr[idx]) {
3333
addr[idx] = b.alloc((s >> 16) & (MSIZE-1));
3434
}

src/coins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return f
1414
uint256 CCoinsView::GetBestBlock() const { return uint256(); }
1515
std::vector<uint256> CCoinsView::GetHeadBlocks() const { return std::vector<uint256>(); }
1616
bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { return false; }
17-
CCoinsViewCursor *CCoinsView::Cursor() const { return 0; }
17+
CCoinsViewCursor *CCoinsView::Cursor() const { return nullptr; }
1818

1919
bool CCoinsView::HaveCoin(const COutPoint &outpoint) const
2020
{

src/httprpc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class HTTPRPCTimerInterface : public RPCTimerInterface
6262
/* Pre-base64-encoded authentication token */
6363
static std::string strRPCUserColonPass;
6464
/* Stored RPC timer interface (for unregistration) */
65-
static HTTPRPCTimerInterface* httpRPCTimerInterface = 0;
65+
static HTTPRPCTimerInterface* httpRPCTimerInterface = nullptr;
6666

6767
static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const UniValue& id)
6868
{
@@ -255,6 +255,6 @@ void StopHTTPRPC()
255255
if (httpRPCTimerInterface) {
256256
RPCUnsetTimerInterface(httpRPCTimerInterface);
257257
delete httpRPCTimerInterface;
258-
httpRPCTimerInterface = 0;
258+
httpRPCTimerInterface = nullptr;
259259
}
260260
}

src/httpserver.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ struct HTTPPathHandler
164164
/** HTTP module state */
165165

166166
//! libevent event loop
167-
static struct event_base* eventBase = 0;
167+
static struct event_base* eventBase = nullptr;
168168
//! HTTP server
169-
struct evhttp* eventHTTP = 0;
169+
struct evhttp* eventHTTP = nullptr;
170170
//! List of subnets to allow RPC connections from
171171
static std::vector<CSubNet> rpc_allow_subnets;
172172
//! Work queue for handling longer requests off the event loop thread
173-
static WorkQueue<HTTPClosure>* workQueue = 0;
173+
static WorkQueue<HTTPClosure>* workQueue = nullptr;
174174
//! Handlers for (sub)paths
175175
std::vector<HTTPPathHandler> pathHandlers;
176176
//! Bound listening sockets
@@ -495,11 +495,11 @@ void StopHTTPServer()
495495
}
496496
if (eventHTTP) {
497497
evhttp_free(eventHTTP);
498-
eventHTTP = 0;
498+
eventHTTP = nullptr;
499499
}
500500
if (eventBase) {
501501
event_base_free(eventBase);
502-
eventBase = 0;
502+
eventBase = nullptr;
503503
}
504504
LogPrint(BCLog::HTTP, "Stopped HTTP server\n");
505505
}
@@ -601,9 +601,9 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply)
601601
evbuffer_add(evb, strReply.data(), strReply.size());
602602
HTTPEvent* ev = new HTTPEvent(eventBase, true,
603603
std::bind(evhttp_send_reply, req, nStatus, (const char*)nullptr, (struct evbuffer *)nullptr));
604-
ev->trigger(0);
604+
ev->trigger(nullptr);
605605
replySent = true;
606-
req = 0; // transferred back to main thread
606+
req = nullptr; // transferred back to main thread
607607
}
608608

609609
CService HTTPRequest::GetPeer()

src/net.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,9 +1438,9 @@ void CConnman::WakeMessageHandler()
14381438
void ThreadMapPort()
14391439
{
14401440
std::string port = strprintf("%u", GetListenPort());
1441-
const char * multicastif = 0;
1442-
const char * minissdpdpath = 0;
1443-
struct UPNPDev * devlist = 0;
1441+
const char * multicastif = nullptr;
1442+
const char * minissdpdpath = nullptr;
1443+
struct UPNPDev * devlist = nullptr;
14441444
char lanaddr[64];
14451445

14461446
#ifndef UPNPDISCOVER_SUCCESS
@@ -1510,13 +1510,13 @@ void ThreadMapPort()
15101510
{
15111511
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
15121512
LogPrintf("UPNP_DeletePortMapping() returned: %d\n", r);
1513-
freeUPNPDevlist(devlist); devlist = 0;
1513+
freeUPNPDevlist(devlist); devlist = nullptr;
15141514
FreeUPNPUrls(&urls);
15151515
throw;
15161516
}
15171517
} else {
15181518
LogPrintf("No valid UPnP IGDs found\n");
1519-
freeUPNPDevlist(devlist); devlist = 0;
1519+
freeUPNPDevlist(devlist); devlist = nullptr;
15201520
if (r != 0)
15211521
FreeUPNPUrls(&urls);
15221522
}

src/netbase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLoo
5050
bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions);
5151
CService LookupNumeric(const char *pszName, int portDefault = 0);
5252
bool LookupSubNet(const char *pszName, CSubNet& subnet);
53-
bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed = 0);
54-
bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed = 0);
53+
bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed = nullptr);
54+
bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed = nullptr);
5555
/** Return readable error string for a network error code */
5656
std::string NetworkErrorString(int err);
5757
/** Close socket and set hSocket to INVALID_SOCKET */

src/support/lockedpool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class LockedPool
150150
* If this callback is provided and returns false, the allocation fails (hard fail), if
151151
* it returns true the allocation proceeds, but it could warn.
152152
*/
153-
LockedPool(std::unique_ptr<LockedPageAllocator> allocator, LockingFailed_Callback lf_cb_in = 0);
153+
LockedPool(std::unique_ptr<LockedPageAllocator> allocator, LockingFailed_Callback lf_cb_in = nullptr);
154154
~LockedPool();
155155

156156
/** Allocate size bytes from this arena.

src/sync.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void DeleteLock(void* cs)
162162
return;
163163
}
164164
boost::unique_lock<boost::mutex> lock(lockdata.dd_mutex);
165-
std::pair<void*, void*> item = std::make_pair(cs, (void*)0);
165+
std::pair<void*, void*> item = std::make_pair(cs, nullptr);
166166
LockOrders::iterator it = lockdata.lockorders.lower_bound(item);
167167
while (it != lockdata.lockorders.end() && it->first.first == cs) {
168168
std::pair<void*, void*> invitem = std::make_pair(it->first.second, it->first.first);

src/torcontrol.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class TorControlConnection
121121
};
122122

123123
TorControlConnection::TorControlConnection(struct event_base *_base):
124-
base(_base), b_conn(0)
124+
base(_base), b_conn(nullptr)
125125
{
126126
}
127127

@@ -227,7 +227,7 @@ bool TorControlConnection::Disconnect()
227227
{
228228
if (b_conn)
229229
bufferevent_free(b_conn);
230-
b_conn = 0;
230+
b_conn = nullptr;
231231
return true;
232232
}
233233

@@ -476,7 +476,7 @@ TorController::~TorController()
476476
{
477477
if (reconnect_ev) {
478478
event_free(reconnect_ev);
479-
reconnect_ev = 0;
479+
reconnect_ev = nullptr;
480480
}
481481
if (service.IsValid()) {
482482
RemoveLocal(service);
@@ -770,7 +770,7 @@ void StopTorControl()
770770
if (gBase) {
771771
torControlThread.join();
772772
event_base_free(gBase);
773-
gBase = 0;
773+
gBase = nullptr;
774774
}
775775
}
776776

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ class CScriptCheck
365365
PrecomputedTransactionData *txdata;
366366

367367
public:
368-
CScriptCheck(): amount(0), ptxTo(0), nIn(0), nFlags(0), cacheStore(false), error(SCRIPT_ERR_UNKNOWN_ERROR) {}
368+
CScriptCheck(): amount(0), ptxTo(nullptr), nIn(0), nFlags(0), cacheStore(false), error(SCRIPT_ERR_UNKNOWN_ERROR) {}
369369
CScriptCheck(const CScript& scriptPubKeyIn, const CAmount amountIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData* txdataIn) :
370370
scriptPubKey(scriptPubKeyIn), amount(amountIn),
371371
ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), error(SCRIPT_ERR_UNKNOWN_ERROR), txdata(txdataIn) { }

0 commit comments

Comments
 (0)