mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Use nullptr instead of zero (0) as the null pointer constant
This commit is contained in:
parent
d451d0bcf1
commit
36d326e8b0
@ -21,14 +21,14 @@ static void BenchLockedPool(benchmark::State& state)
|
||||
|
||||
std::vector<void*> addr;
|
||||
for (int x=0; x<ASIZE; ++x)
|
||||
addr.push_back(0);
|
||||
addr.push_back(nullptr);
|
||||
uint32_t s = 0x12345678;
|
||||
while (state.KeepRunning()) {
|
||||
for (int x=0; x<BITER; ++x) {
|
||||
int idx = s & (addr.size()-1);
|
||||
if (s & 0x80000000) {
|
||||
b.free(addr[idx]);
|
||||
addr[idx] = 0;
|
||||
addr[idx] = nullptr;
|
||||
} else if(!addr[idx]) {
|
||||
addr[idx] = b.alloc((s >> 16) & (MSIZE-1));
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return f
|
||||
uint256 CCoinsView::GetBestBlock() const { return uint256(); }
|
||||
std::vector<uint256> CCoinsView::GetHeadBlocks() const { return std::vector<uint256>(); }
|
||||
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
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ private:
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
@ -164,13 +164,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<CSubNet> rpc_allow_subnets;
|
||||
//! Work queue for handling longer requests off the event loop thread
|
||||
static WorkQueue<HTTPClosure>* workQueue = 0;
|
||||
static WorkQueue<HTTPClosure>* workQueue = nullptr;
|
||||
//! Handlers for (sub)paths
|
||||
std::vector<HTTPPathHandler> pathHandlers;
|
||||
//! Bound listening sockets
|
||||
@ -495,11 +495,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");
|
||||
}
|
||||
@ -601,9 +601,9 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply)
|
||||
evbuffer_add(evb, strReply.data(), strReply.size());
|
||||
HTTPEvent* ev = new HTTPEvent(eventBase, true,
|
||||
std::bind(evhttp_send_reply, req, nStatus, (const char*)nullptr, (struct evbuffer *)nullptr));
|
||||
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()
|
||||
|
10
src/net.cpp
10
src/net.cpp
@ -1438,9 +1438,9 @@ void CConnman::WakeMessageHandler()
|
||||
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
|
||||
@ -1510,13 +1510,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);
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLoo
|
||||
bool Lookup(const char *pszName, std::vector<CService>& 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 */
|
||||
|
@ -150,7 +150,7 @@ public:
|
||||
* 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<LockedPageAllocator> allocator, LockingFailed_Callback lf_cb_in = 0);
|
||||
LockedPool(std::unique_ptr<LockedPageAllocator> allocator, LockingFailed_Callback lf_cb_in = nullptr);
|
||||
~LockedPool();
|
||||
|
||||
/** Allocate size bytes from this arena.
|
||||
|
@ -162,7 +162,7 @@ void DeleteLock(void* cs)
|
||||
return;
|
||||
}
|
||||
boost::unique_lock<boost::mutex> lock(lockdata.dd_mutex);
|
||||
std::pair<void*, void*> item = std::make_pair(cs, (void*)0);
|
||||
std::pair<void*, void*> 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<void*, void*> invitem = std::make_pair(it->first.second, it->first.first);
|
||||
|
@ -121,7 +121,7 @@ private:
|
||||
};
|
||||
|
||||
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);
|
||||
@ -770,7 +770,7 @@ void StopTorControl()
|
||||
if (gBase) {
|
||||
torControlThread.join();
|
||||
event_base_free(gBase);
|
||||
gBase = 0;
|
||||
gBase = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,7 +365,7 @@ private:
|
||||
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) { }
|
||||
|
@ -1644,10 +1644,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;
|
||||
|
@ -739,13 +739,13 @@ DBErrors CWallet::ReorderTransactions()
|
||||
for (std::map<uint256, CWalletTx>::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<CAccountingEntry> 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;
|
||||
@ -754,7 +754,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)
|
||||
{
|
||||
@ -939,7 +939,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);
|
||||
}
|
||||
@ -1004,7 +1004,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)) {
|
||||
@ -1794,7 +1794,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
|
||||
@ -1838,7 +1838,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
|
||||
@ -3026,7 +3026,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;
|
||||
}
|
||||
|
@ -621,7 +621,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;
|
||||
|
@ -15,7 +15,7 @@ typedef CZMQAbstractNotifier* (*CZMQNotifierFactory)();
|
||||
class CZMQAbstractNotifier
|
||||
{
|
||||
public:
|
||||
CZMQAbstractNotifier() : psocket(0) { }
|
||||
CZMQAbstractNotifier() : psocket(nullptr) { }
|
||||
virtual ~CZMQAbstractNotifier();
|
||||
|
||||
template <typename T>
|
||||
|
@ -120,7 +120,7 @@ void CZMQNotificationInterface::Shutdown()
|
||||
}
|
||||
zmq_ctx_destroy(pcontext);
|
||||
|
||||
pcontext = 0;
|
||||
pcontext = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ void CZMQAbstractPublishNotifier::Shutdown()
|
||||
zmq_close(psocket);
|
||||
}
|
||||
|
||||
psocket = 0;
|
||||
psocket = nullptr;
|
||||
}
|
||||
|
||||
bool CZMQAbstractPublishNotifier::SendMessage(const char *command, const void* data, size_t size)
|
||||
@ -136,7 +136,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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user