diff --git a/src/bench/lockedpool.cpp b/src/bench/lockedpool.cpp index 43a1422795434f..c6a05567be9c8f 100644 --- a/src/bench/lockedpool.cpp +++ b/src/bench/lockedpool.cpp @@ -21,14 +21,14 @@ static void BenchLockedPool(benchmark::State& state) std::vector addr; for (int x=0; x> 16) & (MSIZE-1)); } diff --git a/src/coins.cpp b/src/coins.cpp index 4f4b07d5fde88c..4023cdeb95e3bc 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -14,7 +14,7 @@ bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return f uint256 CCoinsView::GetBestBlock() const { return uint256(); } std::vector CCoinsView::GetHeadBlocks() const { return std::vector(); } bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { return false; } -CCoinsViewCursor *CCoinsView::Cursor() const { return 0; } +CCoinsViewCursor *CCoinsView::Cursor() const { return nullptr; } bool CCoinsView::HaveCoin(const COutPoint &outpoint) const { diff --git a/src/httprpc.cpp b/src/httprpc.cpp index b88af33e8d119d..3cd136b17f2550 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -62,7 +62,7 @@ class HTTPRPCTimerInterface : public RPCTimerInterface /* Pre-base64-encoded authentication token */ static std::string strRPCUserColonPass; /* Stored RPC timer interface (for unregistration) */ -static HTTPRPCTimerInterface* httpRPCTimerInterface = 0; +static HTTPRPCTimerInterface* httpRPCTimerInterface = nullptr; static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const UniValue& id) { @@ -255,6 +255,6 @@ void StopHTTPRPC() if (httpRPCTimerInterface) { RPCUnsetTimerInterface(httpRPCTimerInterface); delete httpRPCTimerInterface; - httpRPCTimerInterface = 0; + httpRPCTimerInterface = nullptr; } } diff --git a/src/httpserver.cpp b/src/httpserver.cpp index f047035a65b9fd..ba983eb16b7cc8 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -140,13 +140,13 @@ struct HTTPPathHandler /** HTTP module state */ //! libevent event loop -static struct event_base* eventBase = 0; +static struct event_base* eventBase = nullptr; //! HTTP server -struct evhttp* eventHTTP = 0; +struct evhttp* eventHTTP = nullptr; //! List of subnets to allow RPC connections from static std::vector rpc_allow_subnets; //! Work queue for handling longer requests off the event loop thread -static WorkQueue* workQueue = 0; +static WorkQueue* workQueue = nullptr; //! Handlers for (sub)paths std::vector pathHandlers; //! Bound listening sockets @@ -474,11 +474,11 @@ void StopHTTPServer() } if (eventHTTP) { evhttp_free(eventHTTP); - eventHTTP = 0; + eventHTTP = nullptr; } if (eventBase) { event_base_free(eventBase); - eventBase = 0; + eventBase = nullptr; } LogPrint(BCLog::HTTP, "Stopped HTTP server\n"); } @@ -596,9 +596,9 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply) } } }); - ev->trigger(0); + ev->trigger(nullptr); replySent = true; - req = 0; // transferred back to main thread + req = nullptr; // transferred back to main thread } CService HTTPRequest::GetPeer() diff --git a/src/net.cpp b/src/net.cpp index e4bdd609188df8..7fac4a1e901a7c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1569,9 +1569,9 @@ void CConnman::WakeSelect() void ThreadMapPort() { std::string port = strprintf("%u", GetListenPort()); - const char * multicastif = 0; - const char * minissdpdpath = 0; - struct UPNPDev * devlist = 0; + const char * multicastif = nullptr; + const char * minissdpdpath = nullptr; + struct UPNPDev * devlist = nullptr; char lanaddr[64]; #ifndef UPNPDISCOVER_SUCCESS @@ -1641,13 +1641,13 @@ void ThreadMapPort() { r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0); LogPrintf("UPNP_DeletePortMapping() returned: %d\n", r); - freeUPNPDevlist(devlist); devlist = 0; + freeUPNPDevlist(devlist); devlist = nullptr; FreeUPNPUrls(&urls); throw; } } else { LogPrintf("No valid UPnP IGDs found\n"); - freeUPNPDevlist(devlist); devlist = 0; + freeUPNPDevlist(devlist); devlist = nullptr; if (r != 0) FreeUPNPUrls(&urls); } diff --git a/src/netbase.h b/src/netbase.h index f5db1576bcd924..729fcb4fce4311 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -51,8 +51,8 @@ bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLoo bool Lookup(const char *pszName, std::vector& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions); CService LookupNumeric(const char *pszName, int portDefault = 0); bool LookupSubNet(const char *pszName, CSubNet& subnet); -bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed = 0); -bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed = 0); +bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed = nullptr); +bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed = nullptr); /** Return readable error string for a network error code */ std::string NetworkErrorString(int err); /** Close socket and set hSocket to INVALID_SOCKET */ diff --git a/src/support/lockedpool.h b/src/support/lockedpool.h index f5212bc2666515..7641d8147133c2 100644 --- a/src/support/lockedpool.h +++ b/src/support/lockedpool.h @@ -150,7 +150,7 @@ class LockedPool * If this callback is provided and returns false, the allocation fails (hard fail), if * it returns true the allocation proceeds, but it could warn. */ - LockedPool(std::unique_ptr allocator, LockingFailed_Callback lf_cb_in = 0); + LockedPool(std::unique_ptr allocator, LockingFailed_Callback lf_cb_in = nullptr); ~LockedPool(); /** Allocate size bytes from this arena. diff --git a/src/sync.cpp b/src/sync.cpp index 8fa731b80dee4a..482a2ab0cbf69d 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -176,7 +176,7 @@ void DeleteLock(void* cs) return; } boost::unique_lock lock(lockdata.dd_mutex); - std::pair item = std::make_pair(cs, (void*)0); + std::pair item = std::make_pair(cs, nullptr); LockOrders::iterator it = lockdata.lockorders.lower_bound(item); while (it != lockdata.lockorders.end() && it->first.first == cs) { std::pair invitem = std::make_pair(it->first.second, it->first.first); diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index dd290c08c1bf77..6a515a3928b0f9 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -121,7 +121,7 @@ class TorControlConnection }; TorControlConnection::TorControlConnection(struct event_base *_base): - base(_base), b_conn(0) + base(_base), b_conn(nullptr) { } @@ -227,7 +227,7 @@ bool TorControlConnection::Disconnect() { if (b_conn) bufferevent_free(b_conn); - b_conn = 0; + b_conn = nullptr; return true; } @@ -476,7 +476,7 @@ TorController::~TorController() { if (reconnect_ev) { event_free(reconnect_ev); - reconnect_ev = 0; + reconnect_ev = nullptr; } if (service.IsValid()) { RemoveLocal(service); @@ -776,6 +776,6 @@ void StopTorControl() torControlThread.timed_join(boost::posix_time::seconds(1)); #endif event_base_free(gBase); - gBase = 0; + gBase = nullptr; } } diff --git a/src/validation.h b/src/validation.h index 9e23a456de16aa..c52091b517d766 100644 --- a/src/validation.h +++ b/src/validation.h @@ -383,7 +383,7 @@ class CScriptCheck PrecomputedTransactionData *txdata; public: - CScriptCheck(): amount(0), ptxTo(0), nIn(0), nFlags(0), cacheStore(false), error(SCRIPT_ERR_UNKNOWN_ERROR) {} + CScriptCheck(): amount(0), ptxTo(nullptr), nIn(0), nFlags(0), cacheStore(false), error(SCRIPT_ERR_UNKNOWN_ERROR) {} CScriptCheck(const CScript& scriptPubKeyIn, const CAmount amountIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData* txdataIn) : scriptPubKey(scriptPubKeyIn), amount(amountIn), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), error(SCRIPT_ERR_UNKNOWN_ERROR), txdata(txdataIn) { } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e4e9e73413ade2..7a46c0bc3ff498 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1609,10 +1609,10 @@ UniValue listtransactions(const JSONRPCRequest& request) for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { CWalletTx *const pwtx = (*it).second.first; - if (pwtx != 0) + if (pwtx != nullptr) ListTransactions(pwallet, *pwtx, strAccount, 0, true, ret, filter); CAccountingEntry *const pacentry = (*it).second.second; - if (pacentry != 0) + if (pacentry != nullptr) AcentryToJSON(*pacentry, strAccount, ret); if ((int)ret.size() >= (nCount+nFrom)) break; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fdb5d4e256f385..aa59b8036f43a9 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -939,13 +939,13 @@ DBErrors CWallet::ReorderTransactions() for (std::map::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { CWalletTx* wtx = &((*it).second); - txByTime.insert(std::make_pair(wtx->nTimeReceived, TxPair(wtx, (CAccountingEntry*)0))); + txByTime.insert(std::make_pair(wtx->nTimeReceived, TxPair(wtx, nullptr))); } std::list acentries; walletdb.ListAccountCreditDebit("", acentries); for (CAccountingEntry& entry : acentries) { - txByTime.insert(std::make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); + txByTime.insert(std::make_pair(entry.nTime, TxPair(nullptr, &entry))); } nOrderPosNext = 0; @@ -954,7 +954,7 @@ DBErrors CWallet::ReorderTransactions() { CWalletTx *const pwtx = (*it).second.first; CAccountingEntry *const pacentry = (*it).second.second; - int64_t& nOrderPos = (pwtx != 0) ? pwtx->nOrderPos : pacentry->nOrderPos; + int64_t& nOrderPos = (pwtx != nullptr) ? pwtx->nOrderPos : pacentry->nOrderPos; if (nOrderPos == -1) { @@ -1113,7 +1113,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose) { wtx.nTimeReceived = GetAdjustedTime(); wtx.nOrderPos = IncOrderPosNext(&walletdb); - wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0))); + wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, nullptr))); wtx.nTimeSmart = ComputeTimeSmart(wtx); AddToSpends(hash); @@ -1191,7 +1191,7 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn) mapWallet[hash] = wtxIn; CWalletTx& wtx = mapWallet[hash]; wtx.BindWallet(this); - wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0))); + wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, nullptr))); AddToSpends(hash); for (const CTxIn& txin : wtx.tx->vin) { if (mapWallet.count(txin.prevout.hash)) { @@ -2180,7 +2180,7 @@ CAmount CWalletTx::GetImmatureCredit(bool fUseCache) const CAmount CWalletTx::GetAvailableCredit(bool fUseCache) const { - if (pwallet == 0) + if (pwallet == nullptr) return 0; // Must wait until coinbase is safely deep enough in the chain before valuing it @@ -2224,7 +2224,7 @@ CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool& fUseCache) const CAmount CWalletTx::GetAvailableWatchOnlyCredit(const bool& fUseCache) const { - if (pwallet == 0) + if (pwallet == nullptr) return 0; // Must wait until coinbase is safely deep enough in the chain before valuing it @@ -4103,7 +4103,7 @@ bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB *pwa laccentries.push_back(acentry); CAccountingEntry & entry = laccentries.back(); - wtxOrdered.insert(std::make_pair(entry.nOrderPos, TxPair((CWalletTx*)0, &entry))); + wtxOrdered.insert(std::make_pair(entry.nOrderPos, TxPair(nullptr, &entry))); return true; } diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 5bc457a2f51eb2..53131ef6016262 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -656,7 +656,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) pwallet->laccentries.clear(); ListAccountCreditDebit("*", pwallet->laccentries); for (CAccountingEntry& entry : pwallet->laccentries) { - pwallet->wtxOrdered.insert(make_pair(entry.nOrderPos, CWallet::TxPair((CWalletTx*)0, &entry))); + pwallet->wtxOrdered.insert(make_pair(entry.nOrderPos, CWallet::TxPair(nullptr, &entry))); } return result; diff --git a/src/zmq/zmqabstractnotifier.h b/src/zmq/zmqabstractnotifier.h index 94846dd61266a5..9b9d50addbf11f 100644 --- a/src/zmq/zmqabstractnotifier.h +++ b/src/zmq/zmqabstractnotifier.h @@ -22,7 +22,7 @@ typedef CZMQAbstractNotifier* (*CZMQNotifierFactory)(); class CZMQAbstractNotifier { public: - CZMQAbstractNotifier() : psocket(0) { } + CZMQAbstractNotifier() : psocket(nullptr) { } virtual ~CZMQAbstractNotifier(); template diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp index a33af80c9d4145..e5645f581864b3 100644 --- a/src/zmq/zmqnotificationinterface.cpp +++ b/src/zmq/zmqnotificationinterface.cpp @@ -132,7 +132,7 @@ void CZMQNotificationInterface::Shutdown() } zmq_ctx_destroy(pcontext); - pcontext = 0; + pcontext = nullptr; } } diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp index ab828d8a6f96a8..818d7a202d5f01 100644 --- a/src/zmq/zmqpublishnotifier.cpp +++ b/src/zmq/zmqpublishnotifier.cpp @@ -137,7 +137,7 @@ void CZMQAbstractPublishNotifier::Shutdown() zmq_close(psocket); } - psocket = 0; + psocket = nullptr; } bool CZMQAbstractPublishNotifier::SendMessage(const char *command, const void* data, size_t size) @@ -147,7 +147,7 @@ bool CZMQAbstractPublishNotifier::SendMessage(const char *command, const void* d /* send three parts, command & data & a LE 4byte sequence number */ unsigned char msgseq[sizeof(uint32_t)]; WriteLE32(&msgseq[0], nSequence); - int rc = zmq_send_multipart(psocket, command, strlen(command), data, size, msgseq, (size_t)sizeof(uint32_t), (void*)0); + int rc = zmq_send_multipart(psocket, command, strlen(command), data, size, msgseq, (size_t)sizeof(uint32_t), nullptr); if (rc == -1) return false;