newer standards prefer nullptr over NULL - this is most of them but there are others too

This commit is contained in:
DarthArgus
2016-02-11 15:16:14 -06:00
parent a7f2d0ea6a
commit 3e4cc36e7e
937 changed files with 14983 additions and 14983 deletions
@@ -32,7 +32,7 @@ public:
* @brief Used to retreive the the dot-notation represenatatiion of this address.
*
* @param buffer A pointer to the buffer to place the ip address into.
* Must be at least 17 characters long, will be null terminated.
* Must be at least 17 characters long, will be nullptr terminated.
*
* @return A pointer to the buffer the address was placed into.
*/
@@ -6,7 +6,7 @@ namespace NAMESPACE
#endif
TcpBlockAllocator::TcpBlockAllocator(const unsigned initSize, const unsigned initCount)
: m_freeHead(NULL), m_blockCount(initCount), m_blockSize(initSize), m_numAvailBlocks(0)
: m_freeHead(nullptr), m_blockCount(initCount), m_blockSize(initSize), m_numAvailBlocks(0)
{
realloc();
}
@@ -33,7 +33,7 @@ data_block *TcpBlockAllocator::getBlock()
tmp = m_freeHead;
m_freeHead = m_freeHead->m_next;
tmp->m_next = NULL;
tmp->m_next = nullptr;
m_numAvailBlocks--;
return(tmp);
}
@@ -56,7 +56,7 @@ void TcpBlockAllocator::returnBlock(data_block *b)
void TcpBlockAllocator::realloc()
{
data_block *tmp = NULL, *cursor = NULL;
data_block *tmp = nullptr, *cursor = nullptr;
tmp = new data_block; m_numAvailBlocks++;
cursor = tmp;
@@ -11,28 +11,28 @@ namespace NAMESPACE
//used when want to open new connection with this socket
TcpConnection::TcpConnection(TcpManager *tcpManager, TcpBlockAllocator *sendAlloc, TcpManager::TcpParams &params, const IPAddress &destIP, short destPort, unsigned timeout)
: m_nextConnection(NULL),
m_prevConnection(NULL),
: m_nextConnection(nullptr),
m_prevConnection(nullptr),
m_socket(INVALID_SOCKET),
m_nextKeepAliveConnection(NULL),
m_prevKeepAliveConnection(NULL),
m_nextKeepAliveConnection(nullptr),
m_prevKeepAliveConnection(nullptr),
m_aliveListId(tcpManager->m_aliveList.m_listID),
m_nextRecvDataConnection(NULL),
m_prevRecvDataConnection(NULL),
m_nextRecvDataConnection(nullptr),
m_prevRecvDataConnection(nullptr),
m_recvDataListId(tcpManager->m_dataList.m_listID),
m_manager(tcpManager),
m_status(StatusNegotiating),
m_handler(NULL),
m_handler(nullptr),
m_destIP(destIP),
m_destPort(destPort),
m_refCount(0),
m_sendAllocator(sendAlloc),
m_head(NULL),
m_tail(NULL),
m_head(nullptr),
m_tail(nullptr),
m_bytesRead(0),
m_bytesNeeded(0),
m_params(params),
m_recvBuff(NULL),
m_recvBuff(nullptr),
m_connectTimeout(timeout),
m_connectTimer(),
m_wasConRemovedFromMgr(false)
@@ -94,28 +94,28 @@ TcpConnection::TcpConnection(TcpManager *tcpManager, TcpBlockAllocator *sendAllo
//used when server mode creates new connection object representing a connect request
TcpConnection::TcpConnection(TcpManager *tcpManager, TcpBlockAllocator *sendAlloc, TcpManager::TcpParams &params, SOCKET socket, const IPAddress &destIP, short destPort)
: m_nextConnection(NULL),
m_prevConnection(NULL),
: m_nextConnection(nullptr),
m_prevConnection(nullptr),
m_socket(socket),
m_nextKeepAliveConnection(NULL),
m_prevKeepAliveConnection(NULL),
m_nextKeepAliveConnection(nullptr),
m_prevKeepAliveConnection(nullptr),
m_aliveListId(tcpManager->m_aliveList.m_listID),
m_nextRecvDataConnection(NULL),
m_prevRecvDataConnection(NULL),
m_nextRecvDataConnection(nullptr),
m_prevRecvDataConnection(nullptr),
m_recvDataListId(tcpManager->m_dataList.m_listID),
m_manager(tcpManager),
m_status(StatusConnected),
m_handler(NULL),
m_handler(nullptr),
m_destIP(destIP),
m_destPort(destPort),
m_refCount(0),
m_sendAllocator(sendAlloc),
m_head(NULL),
m_tail(NULL),
m_head(nullptr),
m_tail(nullptr),
m_bytesRead(0),
m_bytesNeeded(0),
m_params(params),
m_recvBuff(NULL),
m_recvBuff(nullptr),
m_connectTimeout(0),
m_connectTimer(),
m_wasConRemovedFromMgr(false)
@@ -205,7 +205,7 @@ int TcpConnection::finishConnect()
t.tv_sec = 0;
t.tv_usec = 0;
int err = select(m_socket + 1, NULL, &wrSet, NULL, &t);
int err = select(m_socket + 1, nullptr, &wrSet, nullptr, &t);
if (err == 0)
{
@@ -300,7 +300,7 @@ TcpConnection::~TcpConnection()
{
delete [] m_recvBuff;
while(m_head != NULL)
while(m_head != nullptr)
{
data_block *tmp = m_head;
m_head = m_head->m_next;
@@ -324,22 +324,22 @@ void TcpConnection::Send(const char *data, unsigned int dataLen)
{
m_aliveListId = m_manager->m_keepAliveList.m_listID;
if (m_prevKeepAliveConnection != NULL)
if (m_prevKeepAliveConnection != nullptr)
m_prevKeepAliveConnection->m_nextKeepAliveConnection = m_nextKeepAliveConnection;
if (m_nextKeepAliveConnection != NULL)
if (m_nextKeepAliveConnection != nullptr)
m_nextKeepAliveConnection->m_prevKeepAliveConnection = m_prevKeepAliveConnection;
if (m_manager->m_keepAliveList.m_beginList == this)
m_manager->m_keepAliveList.m_beginList = m_nextKeepAliveConnection;
m_nextKeepAliveConnection = m_manager->m_aliveList.m_beginList;
m_prevKeepAliveConnection = NULL;
if (m_manager->m_aliveList.m_beginList != NULL)
m_prevKeepAliveConnection = nullptr;
if (m_manager->m_aliveList.m_beginList != nullptr)
m_manager->m_aliveList.m_beginList->m_prevKeepAliveConnection = this;
m_manager->m_aliveList.m_beginList = this;
}
data_block *work = NULL;
data_block *work = nullptr;
// this connection has no send buffer. Get a block
if(!m_tail)
@@ -464,16 +464,16 @@ int TcpConnection::processIncoming()
{
m_recvDataListId = m_manager->m_noDataList.m_listID;
if (m_prevRecvDataConnection != NULL)
if (m_prevRecvDataConnection != nullptr)
m_prevRecvDataConnection->m_nextRecvDataConnection = m_nextRecvDataConnection;
if (m_nextRecvDataConnection != NULL)
if (m_nextRecvDataConnection != nullptr)
m_nextRecvDataConnection->m_prevRecvDataConnection = m_prevRecvDataConnection;
if (m_manager->m_noDataList.m_beginList == this)
m_manager->m_noDataList.m_beginList = m_nextRecvDataConnection;
m_nextRecvDataConnection = m_manager->m_dataList.m_beginList;
m_prevRecvDataConnection = NULL;
if (m_manager->m_dataList.m_beginList != NULL)
m_prevRecvDataConnection = nullptr;
if (m_manager->m_dataList.m_beginList != nullptr)
m_manager->m_dataList.m_beginList->m_prevRecvDataConnection = this;
m_manager->m_dataList.m_beginList = this;
}
@@ -619,7 +619,7 @@ int TcpConnection::processOutgoing()
int sendError = 1;
// If m_head is not null, then this connection has something to send
// If m_head is not nullptr, then this connection has something to send
if(m_head)
@@ -50,7 +50,7 @@ public:
* connection is disconnected, you simply need to derive your class
* (multiply if necessary) from TcpConnectionHandler, then you can use
* this method to set the object the TcpConnection will call as appropriate.
* default = NULL (no callbacks made)
* default = nullptr (no callbacks made)
*
* @param handler The object which will be called for notifications.
*/
@@ -41,14 +41,14 @@ TcpManager::TcpParams::TcpParams(const TcpParams &cpy)
}
TcpManager::TcpManager(const TcpParams &params)
: m_handler(NULL),
m_keepAliveList(NULL, 1),
m_aliveList(NULL, 2),
m_noDataList(NULL, 1),
m_dataList(NULL, 2),
: m_handler(nullptr),
m_keepAliveList(nullptr, 1),
m_aliveList(nullptr, 2),
m_noDataList(nullptr, 1),
m_dataList(nullptr, 2),
m_params(params),
m_refCount(1),
m_connectionList(NULL),
m_connectionList(nullptr),
m_connectionListCount(0),
m_socket(INVALID_SOCKET),
m_boundAsServer(false),
@@ -86,7 +86,7 @@ TcpManager::~TcpManager()
close(m_socket);
#endif
}
while (m_connectionList != NULL)
while (m_connectionList != nullptr)
{
TcpConnection *con = m_connectionList;
m_connectionList = m_connectionList->m_nextConnection;
@@ -162,7 +162,7 @@ bool TcpManager::BindAsServer()
{
struct hostent * lphp;
lphp = gethostbyname(m_params.bindAddress);
if (lphp != NULL)
if (lphp != nullptr)
addr_loc.sin_addr.s_addr = ((struct in_addr *)(lphp->h_addr))->s_addr;
}
else
@@ -187,7 +187,7 @@ bool TcpManager::BindAsServer()
TcpConnection *TcpManager::acceptClient()
{
TcpConnection *newConn = NULL;
TcpConnection *newConn = nullptr;
if (m_boundAsServer && m_connectionListCount < m_params.maxConnections)
{
@@ -201,7 +201,7 @@ TcpConnection *TcpManager::acceptClient()
{
newConn = new TcpConnection(this, &m_allocator, m_params, sock, IPAddress(addr.sin_addr.s_addr), ntohs(addr.sin_port));
addNewConnection(newConn);
if (m_handler != NULL)
if (m_handler != nullptr)
{
m_handler->OnConnectRequest(newConn);
}
@@ -226,8 +226,8 @@ SOCKET TcpManager::getMaxFD()
if (m_boundAsServer)
maxfd = m_socket+1;
TcpConnection *next = NULL;
for (TcpConnection *con = m_connectionList ; con != NULL ; con = next)
TcpConnection *next = nullptr;
for (TcpConnection *con = m_connectionList ; con != nullptr ; con = next)
{
next = con->m_nextConnection;
if (con->GetStatus() != TcpConnection::StatusDisconnected && con->m_socket > maxfd)
@@ -241,8 +241,8 @@ SOCKET TcpManager::getMaxFD()
TcpConnection *TcpManager::getConnection(SOCKET fd)
{
TcpConnection *next = NULL;
for (TcpConnection *con = m_connectionList ; con != NULL ; con = next)
TcpConnection *next = nullptr;
for (TcpConnection *con = m_connectionList ; con != nullptr ; con = next)
{
next = con->m_nextConnection;
if (con->m_socket == fd)
@@ -251,7 +251,7 @@ TcpConnection *TcpManager::getConnection(SOCKET fd)
}
}
//if get here ,couldn't find it
return NULL;
return nullptr;
}
bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendTimePerConnection, unsigned maxRecvTimePerConnection)
@@ -273,8 +273,8 @@ bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendT
{
// Send output from last heartbeat
TcpConnection *next = NULL;
for (TcpConnection *con = m_connectionList ; con != NULL ; con = next)
TcpConnection *next = nullptr;
for (TcpConnection *con = m_connectionList ; con != nullptr ; con = next)
{
con->AddRef();
if (next) next->Release();
@@ -341,7 +341,7 @@ bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendT
tmpfds = m_permfds;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
int cnt = select(maxfd, &tmpfds, NULL, NULL, &timeout); // blocks for timeout
int cnt = select(maxfd, &tmpfds, nullptr, nullptr, &timeout); // blocks for timeout
if (cnt > 0)
@@ -367,8 +367,8 @@ bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendT
//process incoming client messages
if (maxRecvTimePerConnection != 0)
{
TcpConnection *next = NULL;
for (TcpConnection *con = m_connectionList ; con != NULL ; con = next)
TcpConnection *next = nullptr;
for (TcpConnection *con = m_connectionList ; con != nullptr ; con = next)
{
con->AddRef();
if (next) next->Release();
@@ -433,8 +433,8 @@ bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendT
pollfds[0].events |= POLLIN;
}
TcpConnection *next = NULL;
for (TcpConnection *con = m_connectionList ; con != NULL ; con = next, idx++)
TcpConnection *next = nullptr;
for (TcpConnection *con = m_connectionList ; con != nullptr ; con = next, idx++)
{
next = con->m_nextConnection;
pollfds[idx].fd = con->m_socket;
@@ -474,7 +474,7 @@ bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendT
}
//process regular msg(s)
if (con == NULL)
if (con == nullptr)
{
close(pollfds[idx].fd);
continue;
@@ -506,7 +506,7 @@ bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendT
}//if(pollfds[...
else if (pollfds[idx].revents & POLLHUP)
{
if (con == NULL)
if (con == nullptr)
{
close(pollfds[idx].fd);
continue;
@@ -524,21 +524,21 @@ bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendT
//now process any keepalives, if time to do that
if (m_params.keepAliveDelay > 0 && m_keepAliveTimer.isDone(m_params.keepAliveDelay))
{
TcpConnection *next = NULL;
for (TcpConnection *con = m_keepAliveList.m_beginList ; con != NULL ; con = next)
TcpConnection *next = nullptr;
for (TcpConnection *con = m_keepAliveList.m_beginList ; con != nullptr ; con = next)
{
con->AddRef();
if (next) next->Release();
next = con->m_nextKeepAliveConnection;
if (next) next->AddRef();
con->Send(NULL, 0); //note: this request will move the connection from the keepAliveList to the aliveList
con->Send(nullptr, 0); //note: this request will move the connection from the keepAliveList to the aliveList
con->Release();
}
//now move the complete alive list over to the keepalive list to reset those timers
m_keepAliveList.m_beginList = m_aliveList.m_beginList;
m_aliveList.m_beginList = NULL;
m_aliveList.m_beginList = nullptr;
//switch id's for those connections that were in the alive list last go - around
int tmpID = m_aliveList.m_listID;
@@ -552,8 +552,8 @@ bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendT
//now process any noDataCons, if time to do that
if (m_params.noDataTimeout > 0 && m_noDataTimer.isDone(m_params.noDataTimeout))
{
TcpConnection *next = NULL;
for (TcpConnection *con = m_noDataList.m_beginList ; con != NULL ; con = next)
TcpConnection *next = nullptr;
for (TcpConnection *con = m_noDataList.m_beginList ; con != nullptr ; con = next)
{
con->AddRef();
if (next) next->Release();
@@ -567,7 +567,7 @@ bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendT
//now move the complete data list over to the nodata list to reset those timers
m_noDataList.m_beginList = m_dataList.m_beginList;
m_dataList.m_beginList = NULL;
m_dataList.m_beginList = nullptr;
//switch id's for those connections that were in the data list last go - around
int tmpID = m_dataList.m_listID;
@@ -589,11 +589,11 @@ TcpConnection *TcpManager::EstablishConnection(const char *serverAddress, unsign
{
//can't open outgoing connections when in server mode
// use a different TcpManager to do that
return NULL;
return nullptr;
}
if (m_connectionListCount >= m_params.maxConnections)
return(NULL);
return(nullptr);
// get server address
unsigned long address = inet_addr(serverAddress);
@@ -601,8 +601,8 @@ TcpConnection *TcpManager::EstablishConnection(const char *serverAddress, unsign
{
struct hostent * lphp;
lphp = gethostbyname(serverAddress);
if (lphp == NULL)
return(NULL);
if (lphp == nullptr)
return(nullptr);
address = ((struct in_addr *)(lphp->h_addr))->s_addr;
}
IPAddress destIP(address);
@@ -622,22 +622,22 @@ void TcpManager::addNewConnection(TcpConnection *con)
FD_SET(con->m_socket, &m_permfds);
#endif
con->m_nextConnection = m_connectionList;
con->m_prevConnection = NULL;
if (m_connectionList != NULL)
con->m_prevConnection = nullptr;
if (m_connectionList != nullptr)
m_connectionList->m_prevConnection = con;
m_connectionList = con;
m_connectionListCount++;
con->m_nextKeepAliveConnection = m_aliveList.m_beginList;
con->m_prevKeepAliveConnection = NULL;
if (m_aliveList.m_beginList != NULL)
con->m_prevKeepAliveConnection = nullptr;
if (m_aliveList.m_beginList != nullptr)
m_aliveList.m_beginList->m_prevKeepAliveConnection = con;
m_aliveList.m_beginList = con;
con->m_aliveListId = m_keepAliveList.m_listID;//start it out thinking it's already in the alive list, since it is
con->m_nextRecvDataConnection = m_dataList.m_beginList;
con->m_prevRecvDataConnection = NULL;
if (m_dataList.m_beginList != NULL)
con->m_prevRecvDataConnection = nullptr;
if (m_dataList.m_beginList != nullptr)
m_dataList.m_beginList->m_prevRecvDataConnection = con;
m_dataList.m_beginList = con;
con->m_recvDataListId = m_noDataList.m_listID;//start it out thinking it's already in the data list, since it is
@@ -655,40 +655,40 @@ void TcpManager::removeConnection(TcpConnection *con)
FD_CLR(con->m_socket, &m_permfds);
}
#endif
if (con->m_prevConnection != NULL)
if (con->m_prevConnection != nullptr)
con->m_prevConnection->m_nextConnection = con->m_nextConnection;
if (con->m_nextConnection != NULL)
if (con->m_nextConnection != nullptr)
con->m_nextConnection->m_prevConnection = con->m_prevConnection;
if (m_connectionList == con)
m_connectionList = con->m_nextConnection;
con->m_nextConnection = NULL;
con->m_prevConnection = NULL;
con->m_nextConnection = nullptr;
con->m_prevConnection = nullptr;
if (con->m_prevKeepAliveConnection != NULL)
if (con->m_prevKeepAliveConnection != nullptr)
con->m_prevKeepAliveConnection->m_nextKeepAliveConnection = con->m_nextKeepAliveConnection;
if (con->m_nextKeepAliveConnection != NULL)
if (con->m_nextKeepAliveConnection != nullptr)
con->m_nextKeepAliveConnection->m_prevKeepAliveConnection = con->m_prevKeepAliveConnection;
if (m_aliveList.m_beginList == con)
m_aliveList.m_beginList = con->m_nextKeepAliveConnection;
else if (m_keepAliveList.m_beginList == con)
m_keepAliveList.m_beginList = con->m_nextKeepAliveConnection;
con->m_nextKeepAliveConnection = NULL;
con->m_prevKeepAliveConnection = NULL;
con->m_nextKeepAliveConnection = nullptr;
con->m_prevKeepAliveConnection = nullptr;
if (con->m_prevRecvDataConnection != NULL)
if (con->m_prevRecvDataConnection != nullptr)
con->m_prevRecvDataConnection->m_nextRecvDataConnection = con->m_nextRecvDataConnection;
if (con->m_nextRecvDataConnection != NULL)
if (con->m_nextRecvDataConnection != nullptr)
con->m_nextRecvDataConnection->m_prevRecvDataConnection = con->m_prevRecvDataConnection;
if (m_dataList.m_beginList == con)
m_dataList.m_beginList = con->m_nextRecvDataConnection;
else if (m_noDataList.m_beginList == con)
m_noDataList.m_beginList = con->m_nextRecvDataConnection;
con->m_nextRecvDataConnection = NULL;
con->m_prevRecvDataConnection = NULL;
con->m_nextRecvDataConnection = nullptr;
con->m_prevRecvDataConnection = nullptr;
@@ -156,7 +156,7 @@ public:
* simply need to derive your class (multiply if necessary) from TcpManagerHandler, then you can use
* this method to set the object the TcpManager will call as appropriate. The TcpConnection object
* also has a handler mechanism that replaces the other callback functions below, see TcpConnection::SetHandler
* default = NULL (no callbacks made)
* default = nullptr (no callbacks made)
*
* @param handler The object which will be called for manager related notifications.
*/
@@ -211,7 +211,7 @@ public:
* the connect-complete callback to be called if the connection is succesfull.
*
* @return A pointer to a TcpConnection object.
* NULL if the manager object has exceeded its maximum number of connections
* nullptr if the manager object has exceeded its maximum number of connections
* or if the serverAddress cannot be resolved to an IP address.
*/
TcpConnection *EstablishConnection(const char *serverAddress, unsigned short serverPort, unsigned timeout = 0);