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

This reverts commit 8e2160f33e.
This commit is contained in:
DarthArgus
2016-02-11 21:19:18 -06:00
parent 8e2160f33e
commit dd9db6d350
937 changed files with 14983 additions and 14983 deletions
+15 -15
View File
@@ -51,7 +51,7 @@ MonitorObject::~MonitorObject()
if( mConnection )
{
mConnection->SetHandler(NULL);
mConnection->SetHandler(nullptr);
mConnection->Disconnect();
mConnection->Release();
}
@@ -75,10 +75,10 @@ char hold[214];
UdpConnection::DisconnectReasonText( mConnection->GetOtherSideDisconnectReason()));
}
}
mConnection->SetHandler(NULL);
mConnection->SetHandler(nullptr);
mConnection->Disconnect();
mConnection->Release();
mConnection = NULL;
mConnection = nullptr;
}
}
@@ -94,10 +94,10 @@ void MonitorObject::OnRoutePacket( UdpConnection * con, const unsigned char *da
simpleMessage msg(data);
if( con == NULL )
if( con == nullptr )
{
if( mbprint)
fprintf(stderr,"MONITOR API: MonitorObject.OnRoutePacket, recived a NULL connection.?\n");
fprintf(stderr,"MONITOR API: MonitorObject.OnRoutePacket, recived a nullptr connection.?\n");
return;
}
@@ -123,7 +123,7 @@ void MonitorObject::OnRoutePacket( UdpConnection * con, const unsigned char *da
if( mHierarchySent == true )
{
mMonitorData->processElementsRequest(con,mSequence,(char *)&data[6],dataLen,mlastUpdateTime );
mlastUpdateTime = (long)time(NULL);
mlastUpdateTime = (long)time(nullptr);
break;
}
@@ -261,7 +261,7 @@ MonitorManager::MonitorManager(const char *configFile, CMonitorData *_gamedata,
{
mManager = manager;
mbprint = _bprint;
passString = NULL;
passString = nullptr;
mMonitorData = _gamedata;
mObjectCount = 0;
@@ -291,7 +291,7 @@ void MonitorManager::OnConnectRequest(UdpConnection *con)
{
if( con )
{
con->SetHandler(NULL);
con->SetHandler(nullptr);
con->Disconnect();
con->Release();
}
@@ -313,7 +313,7 @@ void MonitorManager::GiveTime()
// check if the monitor object is no longer connected
for (int i = 0; i < mObjectCount; i++)
{
if( mObject[i]->mConnection == NULL ||
if( mObject[i]->mConnection == nullptr ||
mObject[i]->mConnection->GetStatus() == UdpConnection::cStatusDisconnected )
{
MonitorObject *o = mObject[i];
@@ -345,7 +345,7 @@ int x;
char buffer[1024];
FILE *fp = fopen(filename,"r");
if (fp == NULL)
if (fp == nullptr)
{
fprintf(stderr,"Monitor API: could not open %s file\nTHIS FILE IS REQUIRED.\n", filename);
return false;
@@ -367,7 +367,7 @@ char buffer[1024];
x = 0;
while(!feof(fp))
{
if (fgets( buffer, 1023, fp) != NULL) {
if (fgets( buffer, 1023, fp) != nullptr) {
// get rid of '\n' and '\r' for comparisons
strtok(buffer,"\r\n");
len = (int)strlen(buffer);
@@ -403,17 +403,17 @@ CMonitorAPI::CMonitorAPI( const char *configFile, unsigned short Port, bool _bpr
mbprint = _bprint;
mPort = Port;
mAddress = NULL;
mAddress = nullptr;
if( address )
{
mAddress = (char *)malloc(strlen(address)+1);
strcpy(mAddress,address);
}
if( mang == NULL )
if( mang == nullptr )
{
UdpManager::Params params;
params.handler = NULL;
params.handler = nullptr;
params.maxConnections = CONNECTION_MAX;
params.outgoingBufferSize = 1000000;
params.noDataTimeout = 130000;
@@ -595,7 +595,7 @@ int err;
unsigned long S = 4000000;
unsigned char *p;
data = NULL;
data = nullptr;
p = (unsigned char *)malloc(4000000);
memset(p,0,4000000);
err = uncompress(p,&S,(source+6),(long)getSize());
@@ -42,14 +42,14 @@ public:
*
* debug = turn on/off debugging.
*
* address = (NOT USED) Leave as NULL
* address = (NOT USED) Leave as nullptr
*
* UdpManager * mang = (NOT USED) Leave as NULL
* UdpManager * mang = (NOT USED) Leave as nullptr
*
* // GenericNotifier *notifier = (NOT USED) Leave as NULL
* // GenericNotifier *notifier = (NOT USED) Leave as nullptr
*
*/
CMonitorAPI( const char *configFile, unsigned short port, bool debug = false , char * address = NULL, UdpManager * mang = NULL );
CMonitorAPI( const char *configFile, unsigned short port, bool debug = false , char * address = nullptr, UdpManager * mang = nullptr );
~CMonitorAPI();
@@ -112,7 +112,7 @@ public:
* Max Limited
* #define ELEMENT_MAX_START 2000
*/
int add( const char *label, int Key, int mode = MON_HISTORY, const char *Description = NULL );
int add( const char *label, int Key, int mode = MON_HISTORY, const char *Description = nullptr );
/**************** Set the description of an element **
@@ -58,7 +58,7 @@ CMonitorData::CMonitorData()
{
m_sequence = 1;
m_buffer = NULL;
m_buffer = nullptr;
m_nbuffer = 0;
m_count = 0;
m_max = ELEMENT_MAX_START;
@@ -103,7 +103,7 @@ void CMonitorData::resize_buffer(int new_size)
{
char *temp;
if( m_buffer != NULL )
if( m_buffer != nullptr )
{
temp = m_buffer;
m_buffer = new char[ new_size];
@@ -331,7 +331,7 @@ char *p;
if( get_bit(mark,x) == 0 )
{
set_bit( mark, x );
if( m_data[x].discription != NULL )
if( m_data[x].discription != nullptr )
{
sprintf(tmp,"%d,%s|",m_data[x].id, m_data[x].discription);
size += (int)strlen(tmp);
@@ -360,7 +360,7 @@ char *p;
{
flag = 2;
set_bit(mark,x);
if( m_data[x].discription != NULL )
if( m_data[x].discription != nullptr )
{
sprintf(tmp,"%d,%s|",m_data[x].id, m_data[x].discription);
size += (int)strlen(tmp);
@@ -412,7 +412,7 @@ int x;
//******* Discription ******
delete [] m_data[x].discription;
m_data[x].discription = NULL;
m_data[x].discription = nullptr;
if( des )
{
m_data[x].discription = new char [strlen(des)+1];
@@ -459,10 +459,10 @@ int x;
{
if( Id == m_data[x].id )
{
if( Description == NULL )
if( Description == nullptr )
{
delete [] m_data[x].discription;
m_data[x].discription = NULL;
m_data[x].discription = nullptr;
mode = 0;
return x;
}
@@ -510,7 +510,7 @@ int high, i, low;
if ( high < m_count && Id==m_data[high].id )
{
if (m_data[high].ChangedTime == 0 || m_data[high].value != value) {
m_data[high].ChangedTime = (long)time(NULL);
m_data[high].ChangedTime = (long)time(nullptr);
m_data[high].value = value;
}
}
@@ -560,7 +560,7 @@ int CMonitorData::parseList( char **list, char *data, char tok , int max )
int count;
int cnt;
if( data == NULL )
if( data == nullptr )
return 0;
list[0] = data;
@@ -35,7 +35,7 @@ Usage
'L' - long long int (8)
'i' - int (4)
's' - short int (2)
'S' - C-style, null-terminated string (n + null)
'S' - C-style, nullptr-terminated string (n + nullptr)
'Bn' - buffer, of size n. Used for non-terminated strings, or
other binary data.
*/
@@ -115,7 +115,7 @@ private:
//----------------------------------------------------------------
// stringMessage
// This message type is used for passing messages that can consist of a NULL terminated string
// This message type is used for passing messages that can consist of a nullptr terminated string
class stringMessage : public monMessage
{
public:
@@ -252,7 +252,7 @@ class CMonitorData {
public:
// CMonitorData(GenericNotifier *notifier=NULL );
// CMonitorData(GenericNotifier *notifier=nullptr );
CMonitorData();
virtual ~CMonitorData();
@@ -266,7 +266,7 @@ public:
bool processDescriptionRequest(UdpConnection *con, short & sequence, char * userData, int dataLen,unsigned char *mark);
int add(const char *label, int id, int ping, const char *des );
int setDescription( int Id, const char *Description , int & mode);
char *getDescription(int x){ if( m_ndata >= x ) return NULL; return m_data[x].discription;}
char *getDescription(int x){ if( m_ndata >= x ) return nullptr; return m_data[x].discription;}
int pingValue(int p);
void set(int Id, int value);
void remove(int Id);
@@ -42,7 +42,7 @@ CConnectionHandler::~CConnectionHandler()
{
if (mConnection)
{
mConnection->SetHandler(NULL);
mConnection->SetHandler(nullptr);
mConnection->Disconnect();
mConnection->Release();
}
@@ -79,7 +79,7 @@ void CConnectionHandler::OnTerminated(UdpConnection *)
if (mConnection)
{
mConnection->SetHandler(NULL);
mConnection->SetHandler(nullptr);
mConnection->Release();
mConnection = 0;
}
@@ -749,7 +749,7 @@ namespace LoginAPI
else
input.SetSessionID(sessionID);
// don't validate session type, there are clients that pass in NULL.
// don't validate session type, there are clients that pass in nullptr.
input.SetSessionType(sessionType);
////////////////////////////////////////
@@ -776,7 +776,7 @@ namespace LoginAPI
else
input.SetSessionID(sessionID);
// don't validate session type, there are clients that pass in NULL.
// don't validate session type, there are clients that pass in nullptr.
input.SetSessionType(sessionType);
////////////////////////////////////////
@@ -803,7 +803,7 @@ namespace LoginAPI
else
input.SetSessionID(sessionID);
// don't validate session type, there are clients that pass in NULL.
// don't validate session type, there are clients that pass in nullptr.
input.SetSessionType(sessionType);
////////////////////////////////////////
@@ -830,7 +830,7 @@ namespace LoginAPI
else
input.SetSessionID(sessionID);
// don't validate session type, there are clients that pass in NULL.
// don't validate session type, there are clients that pass in nullptr.
input.SetSessionType(sessionType);
////////////////////////////////////////
+2 -2
View File
@@ -91,7 +91,7 @@ namespace Base
ByteStream::ByteStream() :
allocatedSize(0),
beginReadIterator(),
data(NULL),
data(nullptr),
size(0)
{
data = Data::getNewData();
@@ -187,7 +187,7 @@ namespace Base
if(data->size < allocatedSize)
{
unsigned char * tmp = new unsigned char[newSize];
if(data->buffer != NULL)
if(data->buffer != nullptr)
memcpy(tmp, data->buffer, size);
delete[] data->buffer;
data->buffer = tmp;
+15 -15
View File
@@ -35,7 +35,7 @@ bool CAutoLog::Open(const char * filename)
//-------------------------------------
{
if( NULL == filename)
if( nullptr == filename)
return false;
if (pFilename)
@@ -49,13 +49,13 @@ bool CAutoLog::Open(const char * filename)
// Sanitize slashes
char *ptr;
while ((ptr = strchr(pFilename,WRONGSLASH)) != NULL)
while ((ptr = strchr(pFilename,WRONGSLASH)) != nullptr)
*ptr = SLASHCHAR[0];
char strPath[1024];
strcpy(strPath,pFilename);
ptr = strrchr(strPath, SLASHCHAR[0]);
if (ptr != NULL)
if (ptr != nullptr)
{
*ptr = 0;
@@ -63,11 +63,11 @@ bool CAutoLog::Open(const char * filename)
char curdir[128];
// remember current directory
if( _getcwd(curdir,sizeof(curdir)) == NULL )
if( _getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
@@ -78,7 +78,7 @@ bool CAutoLog::Open(const char * filename)
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
}
@@ -98,7 +98,7 @@ bool CAutoLog::Open(const char * filename)
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
}
@@ -107,7 +107,7 @@ bool CAutoLog::Open(const char * filename)
pFile = fopen(pFilename,"a+");
if( pFile == NULL || pFile == (FILE *)-1)
if( pFile == nullptr || pFile == (FILE *)-1)
{
//fprintf(stderr,"CAutoLog::Open failed to open log file: %s\n",pFilename);
Close();
@@ -127,14 +127,14 @@ bool CAutoLog::Open(const char * filename)
void CAutoLog::Close(void)
//-------------------------------------
{
if( pFile != (FILE *)-1 && pFile != NULL)
if( pFile != (FILE *)-1 && pFile != nullptr)
{
fclose(pFile);
}
pFile = (FILE *)-1;
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
}
//-------------------------------------
@@ -197,7 +197,7 @@ void CAutoLog::LogDebug(char * format, ...)
void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == NULL)
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Log called with no file open!\n");
return;
@@ -253,7 +253,7 @@ void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
void CAutoLog::Archive(void)
//-------------------------------------
{
if( pFile == (FILE *)-1 || pFile == NULL)
if( pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Archive called with no file open!\n");
return;
@@ -284,7 +284,7 @@ void CAutoLog::Archive(void)
strcpy(strCurrent,pFilename);
pCurrent = strrchr(strCurrent, SLASHCHAR[0]);
if (pCurrent != NULL)
if (pCurrent != nullptr)
*pCurrent = 0;
else
sprintf(strCurrent,".");
@@ -293,7 +293,7 @@ void CAutoLog::Archive(void)
#ifdef WIN32
// remember current directory
if( _getcwd(curdir,sizeof(curdir)) == NULL )
if( _getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
return; // error, can't proceed
@@ -327,7 +327,7 @@ void CAutoLog::Archive(void)
#endif
pCurrent = strrchr(pFilename, SLASHCHAR[0]);
if (pCurrent == NULL)
if (pCurrent == nullptr)
pCurrent = pFilename;
else
pCurrent++;
+2 -2
View File
@@ -92,14 +92,14 @@ namespace Base
//-------------------------------------
inline CAutoLog::CAutoLog()
{
pFilename = NULL;
pFilename = nullptr;
pFile = (FILE *)-1;
}
//-------------------------------------
inline CAutoLog::CAutoLog(const char * file)
{
pFilename = NULL;
pFilename = nullptr;
pFile = (FILE *)-1;
Open(file);
}
+13 -13
View File
@@ -28,7 +28,7 @@ bool CConfig::LoadFile(char * file)
// open file
fp = fopen(file, "r");
if (fp == NULL || fp == (FILE *)-1)
if (fp == nullptr || fp == (FILE *)-1)
{
//fprintf(stderr,"Failed to open config file %s!",file);
delete fp;
@@ -73,21 +73,21 @@ void CConfig::UnloadFile(void)
//-----------------------------------
{
delete[] pConfig;
pConfig = NULL;
pConfig = nullptr;
}
//-----------------------------------
/// finds a key of the config in memory
// key argument is case-insensitive, but must be upper case in config file
// Returns true for success (passing NULL is a special case returned as success)
// Returns true for success (passing nullptr is a special case returned as success)
bool CConfig::FindKey(char *key)
//-----------------------------------
{
if (pConfig == NULL)
if (pConfig == nullptr)
return false;
// special case...continue with existing key
if (key == NULL)
if (key == nullptr)
return true;
// form the search key
@@ -98,12 +98,12 @@ bool CConfig::FindKey(char *key)
// find the key heading
pCursor = strstr(pConfig,strBuffer);
if (pCursor==NULL)
if (pCursor==nullptr)
return false;
// find the closing bracket of key heading
pCursor = strchr(pCursor,']');
if (pCursor==NULL)
if (pCursor==nullptr)
return false;
pCursor++;
@@ -112,7 +112,7 @@ bool CConfig::FindKey(char *key)
//-----------------------------------
/// extract a number from the config string
// pass the key to find the first number in the list, else NULL to find the next number in the list
// pass the key to find the first number in the list, else nullptr to find the next number in the list
// returns 0 if no number is found, else returns the number
long CConfig::GetLong(char *key)
//-----------------------------------
@@ -135,20 +135,20 @@ long CConfig::GetLong(char *key)
//-----------------------------------
/// extract string (in double-quotes) from the list.
// pass the key to find the first string in the list, else NULL to find the next string in the list
// returns NULL if no string found, else returns a temporary copy of the string (without quotes)
// pass the key to find the first string in the list, else nullptr to find the next string in the list
// returns nullptr if no string found, else returns a temporary copy of the string (without quotes)
char * CConfig::GetString(char *key)
//-----------------------------------
{
if (!FindKey(key))
return NULL;
return nullptr;
// look for start of string or end of key
while (*pCursor && *pCursor != '"' && *pCursor != '[')
pCursor++;
if (*(pCursor++) != '"')
return NULL;
return nullptr;
// until closing quote
int c = 0;
@@ -162,7 +162,7 @@ char * CConfig::GetString(char *key)
}
}
return NULL;
return nullptr;
}
+12 -12
View File
@@ -10,7 +10,7 @@
; list of strings, with code example
# config.FindKey("NUMBERS");
# while (number = config.GetLong(NULL))
# while (number = config.GetLong(nullptr))
# YourHandleNumber(number);
[NUMBERS] 100
200, 300 ; formatting is very flexible as long as numbers are delimited by non-numbers
@@ -23,7 +23,7 @@
; list of strings, with code example
# config.FindKey("HOSTS");
# while (string = config.GetString(NULL))
# while (string = config.GetString(nullptr))
# YourHandleString(string);
[HOSTS]
"206.19.151.173:5999"
@@ -68,16 +68,16 @@ namespace Base
// returns TRUE if key is found.
bool FindKey(char *key);
// extract string from config. If key is NULL, extract next string in list, else extract first string.
// if key was not found, returns NULL
char * GetString(char *key = NULL);
// extract string from config. If key is nullptr, extract next string in list, else extract first string.
// if key was not found, returns nullptr
char * GetString(char *key = nullptr);
// extract number from config. If key is NULL, extract next number in list, else extract first number.
// extract number from config. If key is nullptr, extract next number in list, else extract first number.
// if key was not found, returns 0
long GetLong(char *key = NULL); // extract number from config.
long GetLong(char *key = nullptr); // extract number from config.
// indicate if config file has been loaded
inline bool FileLoaded() { return pConfig == NULL ? false : true; }
inline bool FileLoaded() { return pConfig == nullptr ? false : true; }
private:
char * pConfig; // pointer to file memory
@@ -87,14 +87,14 @@ namespace Base
inline CConfig::CConfig()
{
pConfig = NULL;
pCursor = NULL;
pConfig = nullptr;
pCursor = nullptr;
}
inline CConfig::CConfig(char * file)
{
pConfig = NULL;
pCursor = NULL;
pConfig = nullptr;
pCursor = nullptr;
LoadFile(file);
}
+2 -2
View File
@@ -34,9 +34,9 @@ namespace Base
bool commit = false;
if (!mLastSampleTime)
mLastSampleTime = time(NULL);
mLastSampleTime = time(nullptr);
if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (unsigned)time(NULL))
if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (unsigned)time(nullptr))
{
mSampleTotal++;
mAggregateTotal += value;
@@ -93,7 +93,7 @@ namespace Base
void Destroy(TYPE *object)
{
if (object == NULL)
if (object == nullptr)
return;
#ifdef USE_ALLOCATOR_MUTEX
@@ -142,7 +142,7 @@ namespace Base
void FastDestroy(TYPE *object)
{
if (object == NULL)
if (object == nullptr)
return;
object->~TYPE();
@@ -12,7 +12,7 @@ namespace Base
{
for(unsigned i = 0; i < 31; i++)
{
m_blocks[i] = NULL;
m_blocks[i] = nullptr;
}
}
@@ -21,7 +21,7 @@ namespace Base
// free all allocated memory blocks
for(unsigned i = 0; i < 31; i++)
{
while(m_blocks[i] != NULL)
while(m_blocks[i] != nullptr)
{
unsigned *tmp = m_blocks[i];
m_blocks[i] = (unsigned *)*m_blocks[i];
@@ -36,7 +36,7 @@ namespace Base
void *BlockAllocator::getBlock(unsigned bytes)
{
unsigned accum = 16, bits = 16;
unsigned *handle = NULL;
unsigned *handle = nullptr;
// Perform a binary search looking for the highest bit.
@@ -96,7 +96,7 @@ namespace Base
void BlockAllocator::returnBlock(unsigned *handle)
{
// C++ allows for safe deletion of a NULL pointer
// C++ allows for safe deletion of a nullptr pointer
if(handle)
{
// Update the allocator linked list, insert this entry at the head
+3 -3
View File
@@ -26,8 +26,8 @@ namespace Base
mCond(),
mThreadCount(0)
{
pthread_mutex_init(&mMutex, NULL);
pthread_cond_init(&mCond, NULL);
pthread_mutex_init(&mMutex, nullptr);
pthread_cond_init(&mCond, nullptr);
}
CEvent::~CEvent()
@@ -74,7 +74,7 @@ namespace Base
struct timeval now;
struct timespec abs_timeout;
gettimeofday(&now, NULL);
gettimeofday(&now, nullptr);
abs_timeout.tv_sec = now.tv_sec + timeout/1000;
abs_timeout.tv_nsec = now.tv_usec * 1000 + (timeout%1000)*1000000;
abs_timeout.tv_sec += abs_timeout.tv_nsec / 1000000000;
+9 -9
View File
@@ -18,20 +18,20 @@ Logger::Logger(const char *prefix, int level, unsigned size, bool rollDate)
: m_defaultLevel(level), m_defaultSize(size), m_dirPrefix(prefix), m_rollDate(rollDate)
{
char buf[1024];
FILE *logDir = NULL;
FILE *logDir = nullptr;
logDir = fopen(m_dirPrefix.c_str(), "r+");
if(errno == ENOENT)
{
cmkdir(m_dirPrefix.c_str(), 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
tm now;
time_t t = time(NULL);
time_t t = time(nullptr);
localtime_r(&t, &now);
memcpy(&m_lastDateTime, &now, sizeof(tm));
@@ -48,7 +48,7 @@ Logger::Logger(const char *prefix, int level, unsigned size, bool rollDate)
{
cmkdir(buf, 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -178,7 +178,7 @@ void Logger::logSimple(unsigned logenum, int level, const char *message)
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
{
@@ -241,7 +241,7 @@ void Logger::log(unsigned logenum, int level, const char *message, ...)
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
{
@@ -294,14 +294,14 @@ void Logger::log(unsigned logenum, int level, const char *message, ...)
void Logger::rollDate(time_t t)
{
char buf[80];
FILE *logDir = NULL;
FILE *logDir = nullptr;
logDir = fopen(m_dirPrefix.c_str(), "r+");
if(errno == ENOENT)
{
cmkdir(m_dirPrefix.c_str(), 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -316,7 +316,7 @@ void Logger::rollDate(time_t t)
{
cmkdir(buf, 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
+6 -6
View File
@@ -76,8 +76,8 @@ namespace Base
CThreadPool::CMember::CMember(CThreadPool * parent) :
mParent(parent),
mFunction(NULL),
mArgument(NULL),
mFunction(nullptr),
mArgument(nullptr),
mSemaphore()
{
StartThread();
@@ -116,8 +116,8 @@ namespace Base
if (mFunction)
{
mFunction(mArgument);
mArgument = NULL;
mFunction = NULL;
mArgument = nullptr;
mFunction = nullptr;
}
else if (mParent->OnDestory(this))
mThreadContinue = false;
@@ -172,7 +172,7 @@ namespace Base
}
////////////////////////////////////////
// (3) Delete the null member threads
// (3) Delete the nullptr member threads
mMutex.Lock();
while (!mNullMember.empty())
{
@@ -199,7 +199,7 @@ namespace Base
}
////////////////////////////////////////
// (2) Delete any null member threads.
// (2) Delete any nullptr member threads.
while (!mNullMember.empty())
{
delete mNullMember.front();
@@ -376,8 +376,8 @@ void createTicket()
Plat_Unicode::String xml = narrowToWide("Stress Test XML here");
t.setDetails(details.c_str());
t.setLocation(location.c_str());
track = api->requestCreateTicket(NULL, &t, NULL, t.uid);
//track = api->requestCreateTicket(NULL, &t, xml.c_str(), t.uid);
track = api->requestCreateTicket(nullptr, &t, nullptr, t.uid);
//track = api->requestCreateTicket(nullptr, &t, xml.c_str(), t.uid);
submitted++;
printf("creating ticket\n");
@@ -478,7 +478,7 @@ int main(int argc, char **argv)
gamep = argv[4];
gameserver = argv[5];
if (serverhost == NULL || strlen(serverhost) == 0)
if (serverhost == nullptr || strlen(serverhost) == 0)
{
std::cout << "Missing hostname!\n";
return 0;
@@ -493,12 +493,12 @@ int main(int argc, char **argv)
std::cout << "Missing or invalid number of functions to run!\n";
return 0;
}
if (gamep == NULL || strlen(gamep) == 0)
if (gamep == nullptr || strlen(gamep) == 0)
{
std::cout << "Missing game name!\n";
return 0;
}
if (gameserver == NULL || strlen(gameserver) == 0)
if (gameserver == nullptr || strlen(gameserver) == 0)
{
std::cout << "Missing game server name!\n";
return 0;
@@ -517,7 +517,7 @@ while(1)
unsigned loginWait(500);
unsigned loginAttempts(0);
//api = new apiTest(serverhost, serverport, 60, CSASSIST_APIFLAG_ASSUME_RECONNECT); //, 0, CSASSIST_APIFLAG_ASSUME_RECONNECT);
//api->connectCSAssist(NULL, game.c_str(), server.c_str());
//api->connectCSAssist(nullptr, game.c_str(), server.c_str());
//while (!ready)
// api->Update();
@@ -530,7 +530,7 @@ while(1)
if (api) delete api;
//api = new apiTest(serverhost, serverport, 60, CSASSIST_APIFLAG_ASSUME_RECONNECT);
api = new apiTest(serverhost, serverport, 60, CSASSIST_APIFLAG_ASSUME_RECONNECT|CSASSIST_APIFLAG_NO_REDIRECT);
track = api->connectCSAssist(NULL, game.c_str(), server.c_str());
track = api->connectCSAssist(nullptr, game.c_str(), server.c_str());
loginFailed = false;
std::cout <<"Trying to connect..."<<endl;
Base::sleep(loginWait+=500);
@@ -541,7 +541,7 @@ while(1)
loginAttempts = 0;
loginFailed = true;
delete api;
api = NULL;
api = nullptr;
continue;
}
std::cout <<"Waiting for login: track:" << track<<" ..."<<endl;
@@ -574,21 +574,21 @@ while(1)
case CSASSIST_CALL_NEWTICKETACTIVITY:
character = narrowToWide("Fippy");
if ((rand() % 10) < 5)
track = api->requestNewTicketActivity(NULL, testUID, 0);
track = api->requestNewTicketActivity(nullptr, testUID, 0);
else
track = api->requestNewTicketActivity(NULL, testUID, character.c_str());
track = api->requestNewTicketActivity(nullptr, testUID, character.c_str());
submitted++;
break;
case CSASSIST_CALL_REGISTERCHARACTER:
uid = rand();
track = api->requestRegisterCharacter(NULL, uid, 0, 0);
track = api->requestRegisterCharacter(nullptr, uid, 0, 0);
register_list.push(uid);
submitted++;
break;
case CSASSIST_CALL_GETISSUEHIERARCHY:
lang = narrowToWide("en");
track = api->requestGetIssueHierarchy(NULL, hierarchy.c_str(), lang.c_str());
track = api->requestGetIssueHierarchy(nullptr, hierarchy.c_str(), lang.c_str());
submitted++;
break;
case CSASSIST_CALL_CREATETICKET:
@@ -597,33 +597,33 @@ while(1)
case CSASSIST_CALL_APPENDCOMMENT:
comment = narrowToWide("Unicode comment by player.");
tid = randomTicketID();
track = api->requestAppendTicketComment(NULL, tid, testUID, character.c_str(), comment.c_str());
track = api->requestAppendTicketComment(nullptr, tid, testUID, character.c_str(), comment.c_str());
submitted++;
break;
case CSASSIST_CALL_GETTICKETBYID:
tid = randomTicketID();
track = api->requestGetTicketByID(NULL, tid, 1);
track = api->requestGetTicketByID(nullptr, tid, 1);
submitted++;
break;
case CSASSIST_CALL_GETTICKETCOMMENTS:
tid = randomTicketID();
track = api->requestGetTicketComments(NULL, tid, 0, (rand() % 100)+1, CSASSIST_OFFSET_START);
track = api->requestGetTicketComments(nullptr, tid, 0, (rand() % 100)+1, CSASSIST_OFFSET_START);
submitted++;
break;
case CSASSIST_CALL_GETTICKET:
track = api->requestGetTicketByCharacter(NULL, testUID, character.c_str(), 0, (rand() % 100)+1, 1);
track = api->requestGetTicketByCharacter(nullptr, testUID, character.c_str(), 0, (rand() % 100)+1, 1);
submitted++;
break;
case CSASSIST_CALL_MARKREAD:
tid = randomTicketID();
track = api->requestMarkTicketRead(NULL, tid);
track = api->requestMarkTicketRead(nullptr, tid);
submitted++;
break;
case CSASSIST_CALL_CANCELTICKET:
if (firstTicketID != 0)
{
comment = narrowToWide("Ticket closed by player");
track = api->requestCancelTicket(NULL, firstTicketID, testUID, comment.c_str());
track = api->requestCancelTicket(nullptr, firstTicketID, testUID, comment.c_str());
if (++firstTicketID > lastTicketID)
{
firstTicketID = 0;
@@ -634,33 +634,33 @@ while(1)
break;
case CSASSIST_CALL_COMMENTCOUNT:
tid = randomTicketID();
track = api->requestGetTicketCommentsCount(NULL, tid);
track = api->requestGetTicketCommentsCount(nullptr, tid);
submitted++;
break;
case CSASSIST_CALL_GETDOCUMENTLIST:
// lang = narrowToWide("en");
// track = api->requestGetDocumentList(NULL, hierarchy.c_str(), lang.c_str());
// track = api->requestGetDocumentList(nullptr, hierarchy.c_str(), lang.c_str());
// submitted++;
break;
case CSASSIST_CALL_GETDOCUMENT:
// track = api->requestGetDocument(NULL, 1);
// track = api->requestGetDocument(nullptr, 1);
// submitted++;
break;
case CSASSIST_CALL_GETTICKETXMLBLOCK:
tid = randomTicketID();
track = api->requestGetTicketXMLBlock(NULL, tid);
track = api->requestGetTicketXMLBlock(nullptr, tid);
submitted++;
break;
case CSASSIST_CALL_GETKBARTICLE:
/*id = narrowToWide("soe1401");
lang = narrowToWide("en");
track = api->requestGetKBArticle(NULL, id.c_str(), lang.c_str());
track = api->requestGetKBArticle(nullptr, id.c_str(), lang.c_str());
submitted++;
*/break;
case CSASSIST_CALL_SEARCHKB:
/*Plat_Unicode::String searchStr = narrowToWide("video drivers");
lang = narrowToWide("en");
track = api->requestSearchKB(NULL, searchStr.c_str(), lang.c_str());
track = api->requestSearchKB(nullptr, searchStr.c_str(), lang.c_str());
submitted++;
*/break;
}
@@ -692,7 +692,7 @@ while(1)
{
uid = register_list.front();
register_list.pop();
api->requestUnRegisterCharacter(NULL, uid, 0);
api->requestUnRegisterCharacter(nullptr, uid, 0);
submitted++;
}
cout<<"Waiting for unregisters..."<<endl;
@@ -708,7 +708,7 @@ while(1)
if (elapsed == 0)
elapsed = 1;
cout<<"Going to disconnect now."<<endl;
api->disconnectCSAssist(NULL);
api->disconnectCSAssist(nullptr);
submitted++;
while (submitted > received)
@@ -718,7 +718,7 @@ while(1)
cout<<"Going to delete API now."<<endl;
delete api;
api = NULL;
api = nullptr;
// ----- report findings -----
for (i=0; i < numberFunctions; i++)
@@ -32,7 +32,7 @@ using namespace Plat_Unicode;
//--------------------------------------
CSAssistGameAPIcore::CSAssistGameAPIcore(CSAssistGameAPI *api, const char *host, const unsigned port, const unsigned timeout, const unsigned flags)
: m_connection(NULL),
: m_connection(nullptr),
m_port(port),
m_oldPort(port),
m_connectedPort(0),
@@ -91,7 +91,7 @@ CSAssistGameAPIcore::CSAssistGameAPIcore(CSAssistGameAPI *api, const char *host,
}
CSAssistGameAPIcore::CSAssistGameAPIcore(CSAssistGameAPI *api, const char *serverList, const unsigned timeout, const unsigned flags)
: m_connection(NULL),
: m_connection(nullptr),
m_connectedPort(0),
m_api(api),
m_currTrack(1),
@@ -121,10 +121,10 @@ CSAssistGameAPIcore::CSAssistGameAPIcore(CSAssistGameAPI *api, const char *serve
if (!serverList || (size <= 0))
{
fprintf(stderr, "CSASsistGameAPIcore()::serverList==NULL! aborting...\n");
fprintf(stderr, "CSASsistGameAPIcore()::serverList==nullptr! aborting...\n");
abort();
}
char *p2 = NULL;
char *p2 = nullptr;
char *buf = new char[size+1];
char delims[] = " ,";
char *host = new char[size];
@@ -136,7 +136,7 @@ CSAssistGameAPIcore::CSAssistGameAPIcore(CSAssistGameAPI *api, const char *serve
while (p2)
{
servers.push_back(p2);
p2 = strtok(NULL, delims);
p2 = strtok(nullptr, delims);
}
for (list<string>::iterator iter = servers.begin(); iter != servers.end(); iter++)
{
@@ -147,7 +147,7 @@ CSAssistGameAPIcore::CSAssistGameAPIcore(CSAssistGameAPI *api, const char *serve
memset(host, 0, size);
sprintf(host, "%s", strtok(p, ":"));
int res(1);
char *pc = strtok(NULL, ":");
char *pc = strtok(nullptr, ":");
if (pc) { port = atoi(pc);res++; }
//if (res == 2)
{
@@ -212,7 +212,7 @@ CSAssistGameAPIcore::~CSAssistGameAPIcore()
m_connection->Disconnect(false);
#endif
m_connection->Release();
m_connection = NULL;
m_connection = nullptr;
}
m_conManager->Release();
delete m_receiver;
@@ -298,13 +298,13 @@ void CSAssistGameAPIcore::SubmitRequest(Request *req, Response *res)
{
if (req->getType() != CSASSIST_CALL_CONNECTLB)
{
m_timeout.push(new timeout(res->getTrack(), time(NULL) + m_userTimeout));
req->setTimeout(time(NULL) + m_userTimeout);
m_timeout.push(new timeout(res->getTrack(), time(nullptr) + m_userTimeout));
req->setTimeout(time(nullptr) + m_userTimeout);
}
else
{
m_timeout.push(new timeout(res->getTrack(), time(NULL) + CONNECTLB_TIMEOUT));
req->setTimeout(time(NULL) + CONNECTLB_TIMEOUT);
m_timeout.push(new timeout(res->getTrack(), time(nullptr) + CONNECTLB_TIMEOUT));
req->setTimeout(time(nullptr) + CONNECTLB_TIMEOUT);
}
m_outQueue.push(req);
m_pending.insert(pair<CSAssistGameAPITrack, Response *>(res->getTrack(), res));
@@ -316,13 +316,13 @@ void CSAssistGameAPIcore::SubmitRequestInt(Request *req, Response *res)
{
if (req->getType() != CSASSIST_CALL_CONNECTLB)
{
m_timeoutInt.push(new timeout(res->getTrack(), time(NULL) + m_userTimeout));
req->setTimeout(time(NULL) + m_userTimeout);
m_timeoutInt.push(new timeout(res->getTrack(), time(nullptr) + m_userTimeout));
req->setTimeout(time(nullptr) + m_userTimeout);
}
else
{
m_timeoutInt.push(new timeout(res->getTrack(), time(NULL) + CONNECTLB_TIMEOUT));
req->setTimeout(time(NULL) + CONNECTLB_TIMEOUT);
m_timeoutInt.push(new timeout(res->getTrack(), time(nullptr) + CONNECTLB_TIMEOUT));
req->setTimeout(time(nullptr) + CONNECTLB_TIMEOUT);
}
m_outQueueInt.push(req);
m_pendingInt.insert(pair<CSAssistGameAPITrack, Response *>(res->getTrack(), res));
@@ -390,14 +390,14 @@ void CSAssistGameAPIcore::CSAssistGameCallback(Response *response)
if (!m_receiver->m_firstConnection)
m_api->OnConnectCSAssist(track, result, userData); // normal application layer connect
else
m_api->OnConnectCSAssist(0, result, NULL); // internal re-connect
m_api->OnConnectCSAssist(0, result, nullptr); // internal re-connect
m_receiver->m_firstConnection = true;
}
else
{
if (m_receiver->m_firstConnection)
m_api->OnConnectRejectedCSAssist(0, result, NULL);
m_api->OnConnectRejectedCSAssist(0, result, nullptr);
else
m_api->OnConnectRejectedCSAssist(track, result, userData);
@@ -413,7 +413,7 @@ void CSAssistGameAPIcore::CSAssistGameCallback(Response *response)
m_connection->Disconnect(false);
#endif
m_connection->Release();
m_connection = NULL;
m_connection = nullptr;
}
GetLBHost();
m_receiver->m_firstConnection = true;
@@ -436,7 +436,7 @@ void CSAssistGameAPIcore::CSAssistGameCallback(Response *response)
m_connection->Disconnect(false);
#endif
m_connection->Release();
m_connection = NULL;
m_connection = nullptr;
}
m_api->OnDisconnectCSAssist(track, result, userData);
}
@@ -624,7 +624,7 @@ Response * CSAssistGameAPIcore::getPending(CSAssistGameAPITrack track)
map<CSAssistGameAPITrack, Response *>::iterator iter;
iter = m_pending.find(track);
if (iter == m_pending.end())
return NULL;
return nullptr;
return (*iter).second;
}
@@ -635,7 +635,7 @@ Response * CSAssistGameAPIcore::getPendingInt(CSAssistGameAPITrack track)
map<CSAssistGameAPITrack, Response *>::iterator iter;
iter = m_pendingInt.find(track);
if (iter == m_pendingInt.end())
return NULL;
return nullptr;
return (*iter).second;
}
@@ -681,22 +681,22 @@ void CSAssistGameAPIcore::Update()
// ----- Process timeout queue, send timeout messages when appropriate -----
while((m_timeout.size() > 0) && ((t = m_timeout.front())->time <= time(NULL)))
while((m_timeout.size() > 0) && ((t = m_timeout.front())->time <= time(nullptr)))
{
Response *Res = getPending(t->track);
//fprintf(stderr, "processing timeouts: track(%u) response(%p)\n", t->track, Res);
if(Res != NULL)
if(Res != nullptr)
{
CSAssistGameCallback(Res);
}
m_timeout.pop();
delete t;
}
while((m_timeoutInt.size() > 0) && ((t = m_timeoutInt.front())->time <= time(NULL)))
while((m_timeoutInt.size() > 0) && ((t = m_timeoutInt.front())->time <= time(nullptr)))
{
Response *Res = getPendingInt(t->track);
//fprintf(stderr, "processing internal timeouts: track(%u) response(%p)\n", t->track, Res);
if(Res != NULL)
if(Res != nullptr)
{
CSAssistGameCallback(Res);
}
@@ -705,14 +705,14 @@ void CSAssistGameAPIcore::Update()
}
// ----- process timeouts for requests -----
while ((m_outQueue.size() > 0) && (m_outQueue.front()->getTimeout() <= (unsigned)time(NULL)))
while ((m_outQueue.size() > 0) && (m_outQueue.front()->getTimeout() <= (unsigned)time(nullptr)))
{
Request *R = m_outQueue.front();
//fprintf(stderr, "processing request timeouts: track(%u) request(%u)\n", R->getTrack(), R->getType());
m_outQueue.pop();
delete R;
}
while ((m_outQueueInt.size() > 0) && (m_outQueueInt.front()->getTimeout() <= (unsigned)time(NULL)))
while ((m_outQueueInt.size() > 0) && (m_outQueueInt.front()->getTimeout() <= (unsigned)time(nullptr)))
{
Request *R = m_outQueueInt.front();
//fprintf(stderr, "processing internal request timeouts: track(%u) request(%u)\n", R->getTrack(), R->getType());
@@ -724,18 +724,18 @@ void CSAssistGameAPIcore::Update()
{
// API does not have a connection, begin connection handshake process
//fprintf(stderr, "Going to connect to %s:%d\n", m_ip.c_str(), m_port);
m_reconnectTimeout = time(NULL) + 5;
m_reconnectTimeout = time(nullptr) + 5;
m_connection = m_conManager->EstablishConnection(m_ip.c_str(), m_port);
// set connected host/port before changing with GetLBHost.
m_connectedIP = m_ip.c_str();
m_connectedPort = m_port;
if (m_connection != NULL)
if (m_connection != nullptr)
m_connection->SetHandler(m_receiver);
else
{
m_api->OnConnectRejectedCSAssist(0, CSASSIST_RESULT_FAIL, NULL);
m_api->OnConnectRejectedCSAssist(0, CSASSIST_RESULT_FAIL, nullptr);
// Connection failed. Try getting a new host.
GetLBHost();
}
@@ -777,7 +777,7 @@ void CSAssistGameAPIcore::Update()
else
{
//fprintf(stderr,"Update(1): timing out response(%p) for track(%u)\n", Res, t->track);
if(Res != NULL)
if(Res != nullptr)
{
CSAssistGameCallback(Res);
}
@@ -795,18 +795,18 @@ void CSAssistGameAPIcore::Update()
//fprintf(stderr, "Update(2) enter\n");
#ifdef USE_UDP_LIBRARY
if((m_connection->GetStatus() == UdpConnection::cStatusDisconnected) ||
(m_connection->GetStatus() == UdpConnection::cStatusNegotiating && m_reconnectTimeout < time(NULL)))
(m_connection->GetStatus() == UdpConnection::cStatusNegotiating && m_reconnectTimeout < time(nullptr)))
{
m_connection->Disconnect();
#else
if((m_connection->GetStatus() == TcpConnection::StatusDisconnected) ||
(m_connection->GetStatus() == TcpConnection::StatusNegotiating && m_reconnectTimeout < time(NULL)))
(m_connection->GetStatus() == TcpConnection::StatusNegotiating && m_reconnectTimeout < time(nullptr)))
{
m_connection->Disconnect(false);
#endif
m_connection->Release();
m_connection = NULL;
m_connection = nullptr;
//fprintf(stderr, "Update(2): Disconnected!! m_connectState=%u\n", m_connectState);
switch(m_connectState)
@@ -835,7 +835,7 @@ void CSAssistGameAPIcore::Update()
//if (t->
Response *Res = getPendingInt(t->track);
//fprintf(stderr, "Update(2) timing out connect: track(%u) response(%p)\n", t->track, Res);
if(Res != NULL)
if(Res != nullptr)
{
Res->setResult(CSASSIST_RESULT_FAIL);
CSAssistGameCallback(Res);
@@ -964,7 +964,7 @@ void CSAssistGameAPIcore::Update()
Response *CSAssistGameAPIcore::createServerResponse(short msgtype)
//-------------------------------------------------------------
{
Response *res = NULL;
Response *res = nullptr;
switch (msgtype)
{
@@ -166,11 +166,11 @@ private:
void GetLBHost();
void OnConnectLB(unsigned track, unsigned result, std::string serverName, unsigned serverPort, Request *, Response *);
#ifdef USE_UDP_LIBRARY
inline bool actuallyConnected() { return (bool)((m_connection != NULL) && (m_connection->GetStatus() == UdpConnection::cStatusConnected)); }
inline bool actuallyConnected() { return (bool)((m_connection != nullptr) && (m_connection->GetStatus() == UdpConnection::cStatusConnected)); }
UdpManager *m_conManager;
UdpConnection *m_connection;
#else
inline bool actuallyConnected() { return (bool)((m_connection != NULL) && (m_connection->GetStatus() == TcpConnection::StatusConnected)); }
inline bool actuallyConnected() { return (bool)((m_connection != nullptr) && (m_connection->GetStatus() == TcpConnection::StatusConnected)); }
TcpManager *m_conManager;
TcpConnection *m_connection;
#endif
@@ -99,7 +99,7 @@ void CSAssistReceiver::OnTerminated(TcpConnection *con)
break;
case CONNECT_BACKEND_CONNECTED_AND_AUTHED:
m_api->m_api->OnDisconnectCSAssist(0, CSASSIST_RESULT_SERVER_DISCONNECT, NULL);
m_api->m_api->OnDisconnectCSAssist(0, CSASSIST_RESULT_SERVER_DISCONNECT, nullptr);
case CONNECT_BACKEND_CONNECTED:
m_api->GetLBHost();
case CONNECT_BACKEND_NEGOTIATING: m_api->m_connectState = CONNECT_BACKEND_DISCONNECTED; break;
@@ -110,7 +110,7 @@ void CSAssistReceiver::OnTerminated(TcpConnection *con)
else
{
if (m_api->m_connectState == CONNECT_BACKEND_CONNECTED_AND_AUTHED)
m_api->m_api->OnDisconnectCSAssist(0, CSASSIST_RESULT_SERVER_DISCONNECT, NULL);
m_api->m_api->OnDisconnectCSAssist(0, CSASSIST_RESULT_SERVER_DISCONNECT, nullptr);
m_api->m_connectState = CONNECT_BACKEND_DISCONNECTED;
m_api->GetLBHost();
}
@@ -156,7 +156,7 @@ void CSAssistReceiver::OnRoutePacket(TcpConnection *con, const uchar *data, int
{
res = m_api->getPending(track);
}
if(res != NULL)
if(res != nullptr)
{
res->init(type, track, result);
res->decode(iter);
@@ -40,7 +40,7 @@ Plat_Unicode::String globalArticleID;
//----------------------------------------------
CSAssistUnicodeChar *get_c_str(Plat_Unicode::String s)
// This replaces c_str() by allocating a new buffer, erasing it, and then
// using the non-null terminated data() to copy the data into the buffer.
// using the non-nullptr terminated data() to copy the data into the buffer.
//----------------------------------------------
{
unsigned length = s.size() + 1;
@@ -94,7 +94,7 @@ void DisplayTicket(const CSAssistGameAPITicket *t)
std::cout << wideToNarrow(details) << "\n***\n";
}
else
std::cout << "***Ticket IS NULL! ***\n";
std::cout << "***Ticket IS nullptr! ***\n";
}
//---------------------------------------------
@@ -110,7 +110,7 @@ void DisplayComment(const CSAssistGameAPITicketComment *t)
std::cout << "\n " << wideToNarrow(comment) << "\n";
}
else
std::cout << "***Comment IS NULL! ***\n";
std::cout << "***Comment IS nullptr! ***\n";
}
//---------------------------------------------
@@ -132,7 +132,7 @@ void DisplayDocumentHeader(const CSAssistGameAPIDocumentHeader *doc)
std::cout << ", Modified: " << date2 << "\n";
}
else
std::cout << "***Document Header IS NULL! ***\n";
std::cout << "***Document Header IS nullptr! ***\n";
}
//---------------------------------------------
@@ -148,7 +148,7 @@ void DisplaySearchResult(const CSAssistGameAPISearchResult *doc)
std::cout << ", Title: " << wideToNarrow(title) << "\n";
}
else
std::cout << "***Search Result IS NULL! ***\n";
std::cout << "***Search Result IS nullptr! ***\n";
}
@@ -360,7 +360,7 @@ void apiTest::OnRequestGameLocation(const CSAssistGameAPITrack sourceTrack, cons
CSAssistUnicodeChar *rawLoc = get_c_str(loc);
std::cout << "Request Game Location: Source Track(" << sourceTrack << "), uid(" << uid << "), character(";
std::cout << wideToNarrow(charry) << "), CSR UID(" << CSRUID << ")\n";
api->replyGameLocation(NULL, sourceTrack, uid, rawCharry, CSRUID, rawLoc);
api->replyGameLocation(nullptr, sourceTrack, uid, rawCharry, CSRUID, rawLoc);
delete [] rawCharry;
delete [] rawLoc;
}
@@ -30,7 +30,7 @@ using namespace Plat_Unicode;
//----------------------------------------------
CSAssistUnicodeChar *get_c_str(Plat_Unicode::String s)
// This replaces c_str() by allocating a new buffer, erasing it, and then
// using the non-null terminated data() to copy the data into the buffer.
// using the non-nullptr terminated data() to copy the data into the buffer.
//----------------------------------------------
{
unsigned length = s.size() + 1;
@@ -94,7 +94,7 @@ namespace Base
ByteStream::ByteStream() :
allocatedSize(0),
beginReadIterator(),
data(NULL),
data(nullptr),
size(0),
lastPutSize(0)
{
@@ -211,7 +211,7 @@ namespace Base
if(data->size < allocatedSize)
{
unsigned char * tmp = new unsigned char[newSize];
if(data->buffer != NULL)
if(data->buffer != nullptr)
memcpy(tmp, data->buffer, size);
delete[] data->buffer;
data->buffer = tmp;
@@ -35,7 +35,7 @@ bool CAutoLog::Open(const char * filename)
//-------------------------------------
{
if( NULL == filename)
if( nullptr == filename)
return false;
if (pFilename)
@@ -45,13 +45,13 @@ bool CAutoLog::Open(const char * filename)
// Sanitize slashes
char *ptr;
while ((ptr = strchr(pFilename,WRONGSLASH)) != NULL)
while ((ptr = strchr(pFilename,WRONGSLASH)) != nullptr)
*ptr = SLASHCHAR[0];
char strPath[1024];
strcpy(strPath,pFilename);
ptr = strrchr(strPath, SLASHCHAR[0]);
if (ptr != NULL)
if (ptr != nullptr)
{
*ptr = 0;
@@ -59,11 +59,11 @@ bool CAutoLog::Open(const char * filename)
char curdir[128];
// remember current directory
if( getcwd(curdir,sizeof(curdir)) == NULL )
if( getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
@@ -74,7 +74,7 @@ bool CAutoLog::Open(const char * filename)
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
}
@@ -94,7 +94,7 @@ bool CAutoLog::Open(const char * filename)
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
}
@@ -103,7 +103,7 @@ bool CAutoLog::Open(const char * filename)
pFile = fopen(pFilename,"a+");
if( pFile == NULL || pFile == (FILE *)-1)
if( pFile == nullptr || pFile == (FILE *)-1)
{
//fprintf(stderr,"CAutoLog::Open failed to open log file: %s\n",pFilename);
Close();
@@ -123,7 +123,7 @@ bool CAutoLog::Open(const char * filename)
void CAutoLog::Close(void)
//-------------------------------------
{
if( pFile != (FILE *)-1 && pFile != NULL)
if( pFile != (FILE *)-1 && pFile != nullptr)
{
fclose(pFile);
}
@@ -131,7 +131,7 @@ void CAutoLog::Close(void)
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
}
//-------------------------------------
@@ -194,7 +194,7 @@ void CAutoLog::LogDebug(char * format, ...)
void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == NULL)
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Log called with no file open!\n");
return;
@@ -250,7 +250,7 @@ void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
void CAutoLog::Archive(void)
//-------------------------------------
{
if( pFile == (FILE *)-1 || pFile == NULL)
if( pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Archive called with no file open!\n");
return;
@@ -281,7 +281,7 @@ void CAutoLog::Archive(void)
strcpy(strCurrent,pFilename);
pCurrent = strrchr(strCurrent, SLASHCHAR[0]);
if (pCurrent != NULL)
if (pCurrent != nullptr)
*pCurrent = 0;
else
sprintf(strCurrent,".");
@@ -290,7 +290,7 @@ void CAutoLog::Archive(void)
#ifdef WIN32
// remember current directory
if( getcwd(curdir,sizeof(curdir)) == NULL )
if( getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
return; // error, can't proceed
@@ -324,7 +324,7 @@ void CAutoLog::Archive(void)
#endif
pCurrent = strrchr(pFilename, SLASHCHAR[0]);
if (pCurrent == NULL)
if (pCurrent == nullptr)
pCurrent = pFilename;
else
pCurrent++;
@@ -92,14 +92,14 @@ namespace Base
//-------------------------------------
inline CAutoLog::CAutoLog()
{
pFilename = NULL;
pFilename = nullptr;
pFile = (FILE *)-1;
}
//-------------------------------------
inline CAutoLog::CAutoLog(const char * file)
{
pFilename = NULL;
pFilename = nullptr;
pFile = (FILE *)-1;
Open(file);
}
@@ -28,7 +28,7 @@ bool CConfig::LoadFile(char * file)
// open file
fp = fopen(file, "r");
if (fp == NULL || fp == (FILE *)-1)
if (fp == nullptr || fp == (FILE *)-1)
{
//fprintf(stderr,"Failed to open config file %s!",file);
return false;
@@ -72,21 +72,21 @@ void CConfig::UnloadFile(void)
//-----------------------------------
{
delete[] pConfig;
pConfig = NULL;
pConfig = nullptr;
}
//-----------------------------------
/// finds a key of the config in memory
// key argument is case-insensitive, but must be upper case in config file
// Returns true for success (passing NULL is a special case returned as success)
// Returns true for success (passing nullptr is a special case returned as success)
bool CConfig::FindKey(char *key)
//-----------------------------------
{
if (pConfig == NULL)
if (pConfig == nullptr)
return false;
// special case...continue with existing key
if (key == NULL)
if (key == nullptr)
return true;
// form the search key
@@ -97,12 +97,12 @@ bool CConfig::FindKey(char *key)
// find the key heading
pCursor = strstr(pConfig,strBuffer);
if (pCursor==NULL)
if (pCursor==nullptr)
return false;
// find the closing bracket of key heading
pCursor = strchr(pCursor,']');
if (pCursor==NULL)
if (pCursor==nullptr)
return false;
pCursor++;
@@ -111,7 +111,7 @@ bool CConfig::FindKey(char *key)
//-----------------------------------
/// extract a number from the config string
// pass the key to find the first number in the list, else NULL to find the next number in the list
// pass the key to find the first number in the list, else nullptr to find the next number in the list
// returns 0 if no number is found, else returns the number
long CConfig::GetLong(char *key)
//-----------------------------------
@@ -134,20 +134,20 @@ long CConfig::GetLong(char *key)
//-----------------------------------
/// extract string (in double-quotes) from the list.
// pass the key to find the first string in the list, else NULL to find the next string in the list
// returns NULL if no string found, else returns a temporary copy of the string (without quotes)
// pass the key to find the first string in the list, else nullptr to find the next string in the list
// returns nullptr if no string found, else returns a temporary copy of the string (without quotes)
char * CConfig::GetString(char *key)
//-----------------------------------
{
if (!FindKey(key))
return NULL;
return nullptr;
// look for start of string or end of key
while (*pCursor && *pCursor != '"' && *pCursor != '[')
pCursor++;
if (*(pCursor++) != '"')
return NULL;
return nullptr;
// until closing quote
int c = 0;
@@ -161,7 +161,7 @@ char * CConfig::GetString(char *key)
}
}
return NULL;
return nullptr;
}
+12 -12
View File
@@ -10,7 +10,7 @@
; list of strings, with code example
# config.FindKey("NUMBERS");
# while (number = config.GetLong(NULL))
# while (number = config.GetLong(nullptr))
# YourHandleNumber(number);
[NUMBERS] 100
200, 300 ; formatting is very flexible as long as numbers are delimited by non-numbers
@@ -23,7 +23,7 @@
; list of strings, with code example
# config.FindKey("HOSTS");
# while (string = config.GetString(NULL))
# while (string = config.GetString(nullptr))
# YourHandleString(string);
[HOSTS]
"127.0.0.1:5999"
@@ -68,16 +68,16 @@ namespace Base
// returns TRUE if key is found.
bool FindKey(char *key);
// extract string from config. If key is NULL, extract next string in list, else extract first string.
// if key was not found, returns NULL
char * GetString(char *key = NULL);
// extract string from config. If key is nullptr, extract next string in list, else extract first string.
// if key was not found, returns nullptr
char * GetString(char *key = nullptr);
// extract number from config. If key is NULL, extract next number in list, else extract first number.
// extract number from config. If key is nullptr, extract next number in list, else extract first number.
// if key was not found, returns 0
long GetLong(char *key = NULL); // extract number from config.
long GetLong(char *key = nullptr); // extract number from config.
// indicate if config file has been loaded
inline bool FileLoaded() { return pConfig == NULL ? false : true; }
inline bool FileLoaded() { return pConfig == nullptr ? false : true; }
private:
char * pConfig; // pointer to file memory
@@ -87,14 +87,14 @@ namespace Base
inline CConfig::CConfig()
{
pConfig = NULL;
pCursor = NULL;
pConfig = nullptr;
pCursor = nullptr;
}
inline CConfig::CConfig(char * file)
{
pConfig = NULL;
pCursor = NULL;
pConfig = nullptr;
pCursor = nullptr;
LoadFile(file);
}
@@ -98,7 +98,7 @@ Logger::Logger(const char *programName,
void Logger::LoggerInit(const char *programName)
{
char buf[1024];
FILE *logDir = NULL;
FILE *logDir = nullptr;
if (0 != (m_logType & eUseLocalFile))
{
@@ -107,13 +107,13 @@ void Logger::LoggerInit(const char *programName)
{
cmkdir(m_dirPrefix.c_str(), 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
tm now;
time_t t = time(NULL);
time_t t = time(nullptr);
LOGGER_GET_CURR_TIME(now, t);
@@ -131,7 +131,7 @@ void Logger::LoggerInit(const char *programName)
{
cmkdir(buf, 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -300,7 +300,7 @@ void Logger::logSimple(unsigned logenum, int level, const char *message)
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
{
@@ -377,7 +377,7 @@ void Logger::logSimpleWithSys(unsigned logenum, unsigned priority, int level, co
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
@@ -447,7 +447,7 @@ void Logger::log(unsigned logenum, int level, const char *message, ...)
// ensure that the buf does not contain any '%' characters.
// prevent crash problem
char *rv;
while((rv = strchr(buf, '%')) != NULL)
while((rv = strchr(buf, '%')) != nullptr)
{
*rv = ' '; // replace with space
}
@@ -478,7 +478,7 @@ void Logger::logWithSys(unsigned logenum, unsigned priority, int level, const ch
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
@@ -536,14 +536,14 @@ void Logger::logWithSys(unsigned logenum, unsigned priority, int level, const ch
void Logger::rollDate(time_t t)
{
char buf[80];
FILE *logDir = NULL;
FILE *logDir = nullptr;
logDir = fopen(m_dirPrefix.c_str(), "r+");
if(errno == ENOENT)
{
cmkdir(m_dirPrefix.c_str(), 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -559,7 +559,7 @@ void Logger::rollDate(time_t t)
{
cmkdir(buf, 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -643,7 +643,7 @@ void Logger::rollLog(LogInfo *logInfo)
{
std::string newLogName;
char timeStampBuffer[256];
time_t t = time(NULL);
time_t t = time(nullptr);
tm now;
int r;
int nTries = 10;
@@ -34,9 +34,9 @@ namespace Base
bool commit = false;
if (!mLastSampleTime)
mLastSampleTime = time(NULL);
mLastSampleTime = time(nullptr);
if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (unsigned)time(NULL))
if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (unsigned)time(nullptr))
{
mSampleTotal++;
mAggregateTotal += value;
@@ -93,7 +93,7 @@ namespace Base
void Destroy(TYPE *object)
{
if (object == NULL)
if (object == nullptr)
return;
#ifdef USE_ALLOCATOR_MUTEX
@@ -142,7 +142,7 @@ namespace Base
void FastDestroy(TYPE *object)
{
if (object == NULL)
if (object == nullptr)
return;
object->~TYPE();
@@ -94,12 +94,12 @@ namespace ucs2
}
////////////////////////////////////////
// target string is a null-terminated C string
// target string is a nullptr-terminated C string
inline string::string(const char * copy) :
mLength(0),
mData(8,0)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!copy)
{
return;
@@ -111,12 +111,12 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *copy++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
}
////////////////////////////////////////
// target string is a C string that may or may not include null characters
// target string is a C string that may or may not include nullptr characters
inline string::string(const std::string & copy) :
mLength(copy.length()),
mData(8,0)
@@ -126,17 +126,17 @@ namespace ucs2
// (2) perform transform to copy the narrow string to our
// wide string
std::transform(copy.begin(), copy.end(), mData.begin(), NarrowToWide);
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength] = 0;
}
////////////////////////////////////////
// target string is a wide null-terminated C string
// target string is a wide nullptr-terminated C string
inline string::string(const char_type * copy) :
mLength(0),
mData(8,0)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!copy)
{
return;
@@ -148,7 +148,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *copy++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
}
@@ -169,7 +169,7 @@ namespace ucs2
inline string & string::operator=(const char * rhs)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -182,7 +182,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -195,7 +195,7 @@ namespace ucs2
// (2) perform transform to copy the narrow string to our
// wide string
std::transform(rhs.begin(), rhs.end(), mData.begin(), NarrowToWide);
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength] = 0;
return *this;
}
@@ -203,7 +203,7 @@ namespace ucs2
inline string & string::operator=(const char_type * rhs)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -216,7 +216,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -235,7 +235,7 @@ namespace ucs2
inline string & string::operator+=(const char * rhs)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -247,7 +247,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -259,7 +259,7 @@ namespace ucs2
// (2) perform transform to copy the narrow string to our
// wide string
std::transform(rhs.begin(), rhs.end(), mData.begin()+mLength, NarrowToWide);
// (3) ensure null termination
// (3) ensure nullptr termination
mLength += rhs.length();
mData[mLength] = 0;
return *this;
@@ -267,7 +267,7 @@ namespace ucs2
inline string & string::operator+=(const char_type * rhs)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -279,7 +279,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -388,7 +388,7 @@ namespace ucs2
inline string & string::assign(const char_type * rhs)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -401,7 +401,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -409,7 +409,7 @@ namespace ucs2
inline string & string::assign(const char_type * rhs, size_type count)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -422,7 +422,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -463,7 +463,7 @@ namespace ucs2
inline string & string::assign(const char_type * first, const char_type * last)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!first || !last)
{
mData[0] = 0;
@@ -476,14 +476,14 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *first++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
inline string & string::append(const char_type * rhs)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -495,14 +495,14 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
inline string & string::append(const char_type * rhs, size_type count)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -514,7 +514,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -558,7 +558,7 @@ namespace ucs2
inline string & string::append(const char_type * first, const char_type * last)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!first || !last)
{
return *this;
@@ -570,7 +570,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *first++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -12,7 +12,7 @@ namespace Base
{
for(unsigned i = 0; i < 31; i++)
{
m_blocks[i] = NULL;
m_blocks[i] = nullptr;
}
}
@@ -21,7 +21,7 @@ namespace Base
// free all allocated memory blocks
for(unsigned i = 0; i < 31; i++)
{
while(m_blocks[i] != NULL)
while(m_blocks[i] != nullptr)
{
unsigned *tmp = m_blocks[i];
m_blocks[i] = (unsigned *)*m_blocks[i];
@@ -36,7 +36,7 @@ namespace Base
void *BlockAllocator::getBlock(unsigned bytes)
{
unsigned accum = 16, bits = 16;
unsigned *handle = NULL;
unsigned *handle = nullptr;
// Perform a binary search looking for the highest bit.
@@ -96,7 +96,7 @@ namespace Base
void BlockAllocator::returnBlock(unsigned *handle)
{
// C++ allows for safe deletion of a NULL pointer
// C++ allows for safe deletion of a nullptr pointer
if(handle)
{
// Update the allocator linked list, insert this entry at the head
@@ -26,8 +26,8 @@ namespace Base
mCond(),
mThreadCount(0)
{
pthread_mutex_init(&mMutex, NULL);
pthread_cond_init(&mCond, NULL);
pthread_mutex_init(&mMutex, nullptr);
pthread_cond_init(&mCond, nullptr);
}
CEvent::~CEvent()
@@ -74,7 +74,7 @@ namespace Base
struct timeval now;
struct timespec abs_timeout;
gettimeofday(&now, NULL);
gettimeofday(&now, nullptr);
abs_timeout.tv_sec = now.tv_sec + timeout/1000;
abs_timeout.tv_nsec = now.tv_usec * 1000 + (timeout%1000)*1000000;
abs_timeout.tv_sec += abs_timeout.tv_nsec / 1000000000;
@@ -76,8 +76,8 @@ namespace Base
CThreadPool::CMember::CMember(CThreadPool * parent) :
mParent(parent),
mFunction(NULL),
mArgument(NULL),
mFunction(nullptr),
mArgument(nullptr),
mSemaphore()
{
StartThread();
@@ -116,8 +116,8 @@ namespace Base
if (mFunction)
{
mFunction(mArgument);
mArgument = NULL;
mFunction = NULL;
mArgument = nullptr;
mFunction = nullptr;
}
else if (mParent->OnDestory(this))
mThreadContinue = false;
@@ -172,7 +172,7 @@ namespace Base
}
////////////////////////////////////////
// (3) Delete the null member threads
// (3) Delete the nullptr member threads
mMutex.Lock();
while (!mNullMember.empty())
{
@@ -199,7 +199,7 @@ namespace Base
}
////////////////////////////////////////
// (2) Delete any null member threads.
// (2) Delete any nullptr member threads.
while (!mNullMember.empty())
{
delete mNullMember.front();
@@ -501,8 +501,8 @@ namespace soe
}
else
{
//find null terminator, if don't find it before maxLen, then err
const unsigned char *strEnd = NULL;
//find nullptr terminator, if don't find it before maxLen, then err
const unsigned char *strEnd = nullptr;
unsigned strLen = 0;
for (;strLen<maxLen && strLen < size;strLen++)
{
@@ -513,7 +513,7 @@ namespace soe
break;
}
}
if (strEnd == NULL)
if (strEnd == nullptr)
return 0;
data.assign((const char *)stream, (const char *)strEnd);
@@ -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);
@@ -42,7 +42,7 @@ void TestClient::process()
{
m_con->SetHandler(this);
m_conState = CON_NEGOTIATE;
m_conTimeout = time(NULL) + 20;//m_reconnectTimeout;
m_conTimeout = time(nullptr) + 20;//m_reconnectTimeout;
}
break;
case CON_NEGOTIATE:
@@ -51,10 +51,10 @@ void TestClient::process()
m_conState = CON_CONNECT;
printf("callback here.... connected\n");
}
else if(time(NULL) > 20)
else if(time(nullptr) > 20)
{
m_con->Release();
m_con = NULL;
m_con = nullptr;
m_conState = CON_DISCONNECT;
}
break;
@@ -63,7 +63,7 @@ void TestClient::process()
default:
m_conState = CON_DISCONNECT;
m_con->Release();
m_con = NULL;
m_con = nullptr;
}
m_manager->GiveTime();
}
@@ -95,7 +95,7 @@ void TestClient::OnTerminated(TcpConnection *con)
if (m_con)
{
m_con->Release();
m_con = NULL;
m_con = nullptr;
}
m_conState = CON_DISCONNECT;
}
@@ -122,7 +122,7 @@ namespace Plat_Unicode
/**
* Find a CharData for the given code point.
* @return null if no CharData exists for this code point
* @return nullptr if no CharData exists for this code point
*/
inline const CharData * CharDataMap::findCharData (const unicode_char_t code) const
@@ -87,7 +87,7 @@ int UTF8_convertCharToUTF16( char * ptr , UTF16 * ret )
int UTF8_convertToUTF16( char * ptr , UTF16 * ret, int limit )
{
int len = 0;
while (( *ptr != 0 ) && ( len < ( limit - 1 ) ))//we use limit -1 to leave room for the null terminator
while (( *ptr != 0 ) && ( len < ( limit - 1 ) ))//we use limit -1 to leave room for the nullptr terminator
{
int clen = UTF8_convertCharToUTF16( ptr, ret );
ptr += clen;
@@ -91,7 +91,7 @@ namespace Base
ByteStream::ByteStream() :
allocatedSize(0),
beginReadIterator(),
data(NULL),
data(nullptr),
size(0),
lastPutSize(0)
{
@@ -208,7 +208,7 @@ namespace Base
if(data->size < allocatedSize)
{
unsigned char * tmp = new unsigned char[newSize];
if(data->buffer != NULL)
if(data->buffer != nullptr)
memcpy(tmp, data->buffer, size);
delete[] data->buffer;
data->buffer = tmp;
@@ -117,7 +117,7 @@ unsigned GenericAPICore::submitRequest(GenericRequest *req, GenericResponse *res
}
req->setTrack(m_currTrack);
res->setTrack(m_currTrack);
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -136,7 +136,7 @@ void GenericAPICore::process()
if (!m_suspended)
{
// Process timeout on pending requests
while((m_outCount > 0) && ((req = m_outboundQueue.front().first)->getTimeout() <= time(NULL)))
while((m_outCount > 0) && ((req = m_outboundQueue.front().first)->getTimeout() <= time(nullptr)))
{
--m_outCount;
res = m_outboundQueue.front().second;
@@ -148,7 +148,7 @@ void GenericAPICore::process()
}
// Process timeout on pending responses
while((m_pendingCount > 0) && ((res = (*m_pending.begin()).second)->getTimeout() <= time(NULL)))
while((m_pendingCount > 0) && ((res = (*m_pending.begin()).second)->getTimeout() <= time(nullptr)))
{
--m_pendingCount;
m_pending.erase(m_pending.begin());
@@ -161,7 +161,7 @@ void GenericAPICore::process()
pair<GenericRequest *, GenericResponse *> out_pair = m_outboundQueue.front();
req = out_pair.first;
res = out_pair.second;
GenericConnection *con = NULL;
GenericConnection *con = nullptr;
if (req->getMappedServerTrack() == 0) // request has no originating "owner" server
{
con = getNextActiveConnection(); // it does not matter which server we send this to
@@ -178,7 +178,7 @@ void GenericAPICore::process()
}
}
if (con != NULL)
if (con != nullptr)
{
Base::ByteStream msg;
req->pack(msg);
@@ -213,7 +213,7 @@ GenericConnection *GenericAPICore::getNextActiveConnection()
unsigned startIndex = m_nextConnectionIndex;
unsigned maxIndex = m_serverConnections.size() - 1;
GenericConnection *con = NULL;
GenericConnection *con = nullptr;
//loop until we find an active connection, or until we get back
// to where we started
@@ -233,7 +233,7 @@ GenericConnection *GenericAPICore::getNextActiveConnection()
//went past end of vector, start back at 0
m_nextConnectionIndex = 0;
}
}while (con == NULL && m_nextConnectionIndex != startIndex);
}while (con == nullptr && m_nextConnectionIndex != startIndex);
return con;
}
@@ -259,7 +259,7 @@ ServerTrackObject *GenericAPICore::findServer(unsigned server_track)
{
std::map<unsigned, ServerTrackObject *>::iterator iter = m_serverTracks.find(server_track);
if (iter == m_serverTracks.end())
return NULL;
return nullptr;
ServerTrackObject *stobj = (*iter).second;
m_serverTracks.erase(server_track);
return stobj;
@@ -22,7 +22,7 @@ using namespace Base;
GenericConnection::GenericConnection(const char *host, short port, GenericAPICore *apiCore, unsigned reconnectTimeout, unsigned noDataTimeoutSecs, unsigned noAckTimeoutSecs, unsigned incomingBufSizeInKB, unsigned outgoingBufSizeInKB, unsigned keepAlive, unsigned maxRecvMessageSizeInKB)
: m_bConnected(CON_NONE),
m_apiCore(apiCore),
m_con(NULL),
m_con(nullptr),
m_host(host),
m_port(port),
m_lastTrack(123455), //random choice != 1
@@ -47,8 +47,8 @@ GenericConnection::~GenericConnection()
{
if(m_con)
{
m_con->SetHandler(NULL);
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to null, so it wont
m_con->SetHandler(nullptr);
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to nullptr, so it wont
m_con->Release();
}
@@ -61,7 +61,7 @@ void GenericConnection::disconnect()
{
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
m_con = nullptr;
}
m_conState = CON_DISCONNECT;
m_bConnected = CON_NONE;
@@ -74,7 +74,7 @@ void GenericConnection::OnTerminated(TcpConnection *con)
if(m_con)
{
m_con->Release();
m_con = NULL;
m_con = nullptr;
}
m_conState = CON_DISCONNECT;
m_bConnected = CON_NONE;
@@ -90,7 +90,7 @@ void GenericConnection::OnRoutePacket(TcpConnection *con, const unsigned char *d
get(iter, type);
get(iter, track);
GenericResponse *res = NULL;
GenericResponse *res = nullptr;
// the following if block is a temporary fix that prevents
// a crash with a game team in which they occasionally find
@@ -148,7 +148,7 @@ void GenericConnection::process()
{
m_con->SetHandler(this);
m_conState = CON_NEGOTIATE;
m_conTimeout = time(NULL) + m_reconnectTimeout;
m_conTimeout = time(nullptr) + m_reconnectTimeout;
}
break;
case CON_NEGOTIATE:
@@ -169,12 +169,12 @@ void GenericConnection::process()
put(msg, m_apiCore->getGameCode());
Send(msg);
}
else if(time(NULL) > m_conTimeout)
else if(time(nullptr) > m_conTimeout)
{
// we did not connect
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
m_con = nullptr;
m_conState = CON_DISCONNECT;
m_bConnected = CON_NONE;
}
@@ -190,7 +190,7 @@ void GenericConnection::process()
{
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
m_con = nullptr;
}
}
m_manager->GiveTime();
@@ -23,7 +23,7 @@ CTServiceAPI::CTServiceAPI(const char *hostName, const char *game)
std::vector<const char *> hostArray;
std::vector<short> portArray;
char hostConfig[4096];
if (hostName == NULL)
if (hostName == nullptr)
hostName = DEFAULT_HOST;
if (!game)
game = DEFAULT_GAMECODE;
@@ -47,7 +47,7 @@ CTServiceAPI::CTServiceAPI(const char *hostName, const char *game)
portArray.push_back(port);
}
}
while ((ptr = strtok(NULL, " ")) != NULL);
while ((ptr = strtok(nullptr, " ")) != nullptr);
}
if (hostArray.empty())
{
@@ -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);
@@ -10,7 +10,7 @@
using namespace CTService;
unsigned openRequests = 0;
CTServiceAPI *waitclient = NULL;
CTServiceAPI *waitclient = nullptr;
std::map<unsigned, unsigned> m_tests;
std::string game_code;
@@ -122,7 +122,7 @@ namespace Plat_Unicode
/**
* Find a CharData for the given code point.
* @return null if no CharData exists for this code point
* @return nullptr if no CharData exists for this code point
*/
inline const CharData * CharDataMap::findCharData (const unicode_char_t code) const
@@ -135,7 +135,7 @@ namespace CTService
const char *game,
const char *param)
{
printf("onServerTest(%u, %s, %s)\n", server_track, game ? game : "(null)", param ? param : "(null)");
printf("onServerTest(%u, %s, %s)\n", server_track, game ? game : "(nullptr)", param ? param : "(nullptr)");
replyTest(server_track, 999, 0);
}
@@ -9,7 +9,7 @@ namespace ChatSystem
// AVATAR ITERATOR CORE
AvatarIteratorCore::AvatarIteratorCore()
: m_map(NULL)
: m_map(nullptr)
{
}
@@ -33,7 +33,7 @@ AvatarIteratorCore &AvatarIteratorCore::operator=(const AvatarIteratorCore& rhs)
ChatAvatar *AvatarIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -87,7 +87,7 @@ bool AvatarIteratorCore::outOfBounds()
// MODERATOR ITERATOR CORE
ModeratorIteratorCore::ModeratorIteratorCore()
: m_set(NULL)
: m_set(nullptr)
{
}
@@ -111,7 +111,7 @@ ModeratorIteratorCore &ModeratorIteratorCore::operator=(const ModeratorIteratorC
ChatAvatar *ModeratorIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -165,7 +165,7 @@ bool ModeratorIteratorCore::outOfBounds()
// TEMPORARY MODERATOR ITERATOR CORE
TemporaryModeratorIteratorCore::TemporaryModeratorIteratorCore()
: m_set(NULL)
: m_set(nullptr)
{
}
@@ -189,7 +189,7 @@ TemporaryModeratorIteratorCore &TemporaryModeratorIteratorCore::operator=(const
ChatAvatar *TemporaryModeratorIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -243,7 +243,7 @@ bool TemporaryModeratorIteratorCore::outOfBounds()
// VOICE ITERATOR CORE
VoiceIteratorCore::VoiceIteratorCore()
: m_set(NULL)
: m_set(nullptr)
{
}
@@ -267,7 +267,7 @@ VoiceIteratorCore &VoiceIteratorCore::operator=(const VoiceIteratorCore& rhs)
ChatAvatar *VoiceIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -321,7 +321,7 @@ bool VoiceIteratorCore::outOfBounds()
// INVITE ITERATOR CORE
InviteIteratorCore::InviteIteratorCore()
: m_set(NULL)
: m_set(nullptr)
{
}
@@ -345,7 +345,7 @@ InviteIteratorCore &InviteIteratorCore::operator=(const InviteIteratorCore& rhs)
ChatAvatar *InviteIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -399,7 +399,7 @@ bool InviteIteratorCore::outOfBounds()
// BAN ITERATOR CORE
BanIteratorCore::BanIteratorCore()
: m_set(NULL)
: m_set(nullptr)
{
}
@@ -423,7 +423,7 @@ BanIteratorCore &BanIteratorCore::operator=(const BanIteratorCore& rhs)
ChatAvatar *BanIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -7,7 +7,7 @@ namespace ChatSystem
using namespace Plat_Unicode;
AvatarListItem::AvatarListItem()
: m_core(NULL)
: m_core(nullptr)
{
}
@@ -16,7 +16,7 @@ namespace ChatSystem
}
AvatarListItemCore::AvatarListItemCore()
: m_interface(NULL)
: m_interface(nullptr)
{
}
@@ -13,7 +13,7 @@ namespace ChatSystem
{
ChatAPI::ChatAPI(const char *registrar_host, short registrar_port, const char *server_host, short server_port)
: m_defaultRoomParams(NULL),
: m_defaultRoomParams(nullptr),
m_defaultLoginPriority(0),
m_defaultEntryType(false)
{
@@ -25,13 +25,13 @@ ChatAPI::ChatAPI(const char *registrar_host, short registrar_port, const char *s
ChatAPI::~ChatAPI()
{
delete m_defaultRoomParams;
m_defaultRoomParams = NULL;
m_defaultRoomParams = nullptr;
delete m_core;
m_core = NULL;
m_core = nullptr;
}
ChatAPI::ChatAPI(ChatAPICore *core)
: m_defaultRoomParams(NULL)
: m_defaultRoomParams(nullptr)
{
m_core = core;
m_core->setAPI(this);
@@ -721,7 +721,7 @@ void ChatAPI::setDefaultRoomParams(RoomParams *roomParams)
{
if (roomParams)
{
if (m_defaultRoomParams == NULL)
if (m_defaultRoomParams == nullptr)
{
m_defaultRoomParams = new RoomParams;
}
@@ -732,7 +732,7 @@ void ChatAPI::setDefaultRoomParams(RoomParams *roomParams)
else
{
delete m_defaultRoomParams;
m_defaultRoomParams = NULL;
m_defaultRoomParams = nullptr;
}
}
void ChatAPI::setDefaultLoginLocation(const ChatUnicodeString &defaultLoginLocation)
@@ -105,7 +105,7 @@ namespace ChatSystem
// will be connected to, as well as the hostname and port of the Registrar
// ChatServer (which will automatically reroute the ChatAPI connection to
// a hotspare ChatServer if the provided choice is unavailable).
// NULL pointers are NOT valid input.
// nullptr pointers are NOT valid input.
ChatAPI(const char *registrar_host, short registrar_port, const char *server_host, short server_port);
virtual ~ChatAPI();
@@ -209,7 +209,7 @@ namespace ChatSystem
// getAvatar
// Requests immediate return of a ChatAvatar object that this API
// has cached due to a RequestLoginAvatar. Request does not go
// to ChatServer. Returns NULL if API does not have object locally.
// to ChatServer. Returns nullptr if API does not have object locally.
ChatAvatar *getAvatar(const ChatUnicodeString &avatarName, const ChatUnicodeString &avatarAddress);
ChatAvatar *getAvatar(unsigned avatarID);
@@ -286,7 +286,7 @@ namespace ChatSystem
// Requests immediate return of a ChatRoom object that this API
// has cached due to a RequestGetRoom, RequestCreateRoom, or
// RequestEnterRoom. Request does not go to ChatServer. Returns
// NULL if API does not have object locally.
// nullptr if API does not have object locally.
ChatRoom *getRoom(const ChatUnicodeString &roomAddress);
ChatRoom *getRoom(unsigned roomID);
@@ -298,13 +298,13 @@ namespace ChatSystem
// getDefaultRoomParams
// Requests the ChatAPI's current default RoomParams object. Used for
// the EnterRoom call. If NULL, EnterRoom will not do passive room
// the EnterRoom call. If nullptr, EnterRoom will not do passive room
// creation if the room to enter does not yet exist. Initial value
// is NULL (no RoomParams object defined).
// is nullptr (no RoomParams object defined).
const RoomParams *getDefaultRoomParams(void);
// setDefaultRoomParams
// Sets the ChatAPI's current default RoomParams object. Passing a NULL
// Sets the ChatAPI's current default RoomParams object. Passing a nullptr
// pointer will cause the default params not to be used by EnterRoom.
void setDefaultRoomParams(RoomParams *roomParams);
@@ -67,7 +67,7 @@ const char * const ChatAPICore::ms_errorStringsEnglish[] =
"UID node already exists",
"Wrong chat server for request",
"Succeeded, but local data is invalid",
"Login with null name",
"Login with nullptr name",
"No server assigned to this identity", // 45
"Another server already assumed this identity",
"Remote server is down",
@@ -82,9 +82,9 @@ const char * const ChatAPICore::ms_errorStringsEnglish[] =
"Duplicate voice",
"Chat avatar must first be logged out",
"No work to do",
"Cannot perform rename to NULL avatar name",
"Cannot perform rename to nullptr avatar name",
"Cannot perform station acct transfer to stationID = 0", // 60
"Cannot perform avatar move to NULL avatar address",
"Cannot perform avatar move to nullptr avatar address",
"Failed to obtain an ID for a new room or avatar",
"Room is local to namespace/world; cannot enter from other worlds",
"Room is local to game; cannot enter from other game namespaces",
@@ -122,7 +122,7 @@ ChatAPICore::ChatAPICore(const char *registrar_host, short registrar_port, const
m_registrarPort(registrar_port),
m_defaultServerPort(server_port),
m_assignedServerPort(server_port),
m_timeSinceLastDisconnect(time(NULL)),
m_timeSinceLastDisconnect(time(nullptr)),
m_rcvdRegistrarResponse(false),
m_shouldSendVersion(true)
{
@@ -132,7 +132,7 @@ ChatAPICore::ChatAPICore(const char *registrar_host, short registrar_port, const
ChatAPICore::~ChatAPICore()
{
m_api = NULL;
m_api = nullptr;
std::map<unsigned, ChatAvatarCore*>::iterator iter = m_avatarCoreCache.begin();
for (; iter != m_avatarCoreCache.end(); ++iter)
@@ -209,7 +209,7 @@ void ChatAPICore::cacheAvatar(ChatAvatarCore *avatarCore)
ChatAvatarCore *ChatAPICore::getAvatarCore(unsigned avatarID)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
std::map<unsigned, ChatAvatarCore *>::iterator iter = m_avatarCoreCache.find(avatarID);
if(iter != m_avatarCoreCache.end())
@@ -221,7 +221,7 @@ ChatAvatarCore *ChatAPICore::getAvatarCore(unsigned avatarID)
ChatAvatar *ChatAPICore::getAvatar(unsigned avatarID)
{
ChatAvatar *returnAvatar = NULL;
ChatAvatar *returnAvatar = nullptr;
std::map<unsigned, ChatAvatar *>::iterator iter = m_avatarCache.find(avatarID);
if(iter != m_avatarCache.end())
@@ -233,7 +233,7 @@ ChatAvatar *ChatAPICore::getAvatar(unsigned avatarID)
ChatAvatarCore *ChatAPICore::decacheAvatar(unsigned avatarID)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
std::map<unsigned, ChatAvatarCore *>::iterator iterCore = m_avatarCoreCache.find(avatarID);
if(iterCore != m_avatarCoreCache.end())
{
@@ -267,7 +267,7 @@ void ChatAPICore::cacheRoom(ChatRoomCore *roomCore)
ChatRoomCore *ChatAPICore::getRoomCore(unsigned roomID)
{
ChatRoomCore *returnRoom = NULL;
ChatRoomCore *returnRoom = nullptr;
std::map<unsigned, ChatRoomCore *>::iterator iter = m_roomCoreCache.find(roomID);
if(iter != m_roomCoreCache.end())
{
@@ -279,7 +279,7 @@ ChatRoomCore *ChatAPICore::getRoomCore(unsigned roomID)
ChatRoom *ChatAPICore::getRoom(unsigned roomID)
{
ChatRoom *returnRoom = NULL;
ChatRoom *returnRoom = nullptr;
std::map<unsigned, ChatRoom *>::iterator iter = m_roomCache.find(roomID);
if(iter != m_roomCache.end())
{
@@ -291,7 +291,7 @@ ChatRoom *ChatAPICore::getRoom(unsigned roomID)
ChatRoomCore *ChatAPICore::decacheRoom(unsigned roomID)
{
ChatRoomCore *returnRoom = NULL;
ChatRoomCore *returnRoom = nullptr;
std::map<unsigned, ChatRoomCore *>::iterator iterCore = m_roomCoreCache.find(roomID);
if(iterCore != m_roomCoreCache.end())
@@ -315,7 +315,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_LOGINAVATAR:
{
ResLoginAvatar *R = static_cast<ResLoginAvatar *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getAvatar())
{
@@ -338,7 +338,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_TEMPORARYAVATAR:
{
ResTemporaryAvatar* R = static_cast<ResTemporaryAvatar*>(res);
ChatAvatar* avatar = NULL;
ChatAvatar* avatar = nullptr;
if ( R->getAvatar() )
{
@@ -394,8 +394,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_GETAVATAR:
{
ResGetAvatar *R = static_cast<ResGetAvatar *>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -403,7 +403,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatarCore->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
// update cached information with returned data
cachedAvatar->setAttributes(avatarCore->getAttributes());
@@ -427,7 +427,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
m_api->OnGetAvatar(R->getTrack(), R->getResult(), avatar, R->getUser());
if (cachedAvatar == NULL)
if (cachedAvatar == nullptr)
{
delete avatar;
}
@@ -438,8 +438,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_GETANYAVATAR:
{
ResGetAnyAvatar *R = static_cast<ResGetAnyAvatar *>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -447,7 +447,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatarCore->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
// update cached information with returned data
cachedAvatar->setAttributes(avatarCore->getAttributes());
@@ -471,7 +471,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
m_api->OnGetAnyAvatar(R->getTrack(), R->getResult(), avatar, R->isLoggedIn(), R->getUser());
if (cachedAvatar == NULL)
if (cachedAvatar == nullptr)
{
delete avatar;
}
@@ -490,8 +490,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SETAVATARATTRIBUTES:
{
ResSetAvatarAttributes *R = static_cast<ResSetAvatarAttributes *>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -502,14 +502,14 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatar->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar->setAttributes(avatar->getAttributes());
}
}
}
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar = avatar;
m_api->OnSetAvatarAttributes(R->getTrack(), R->getResult(), cachedAvatar, R->getUser());
@@ -531,8 +531,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SETSTATUSMESSAGE:
{
ResSetAvatarStatusMessage *R = static_cast<ResSetAvatarStatusMessage*>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -543,14 +543,14 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatar->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar->setStatusMessage(avatar->getStatusMessage());
}
}
}
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar = avatar;
m_api->OnSetAvatarStatusMessage(R->getTrack(), R->getResult(), cachedAvatar, R->getUser());
@@ -572,8 +572,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SETAVATAREMAIL:
{
ResSetAvatarForwardingEmail*R = static_cast<ResSetAvatarForwardingEmail*>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -584,14 +584,14 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatar->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar->setForwardingEmail(avatar->getForwardingEmail());
}
}
}
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar = avatar;
m_api->OnSetAvatarForwardingEmail(R->getTrack(), R->getResult(), cachedAvatar, R->getUser());
@@ -613,8 +613,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SETAVATARINBOXLIMIT:
{
ResSetAvatarInboxLimit *R = static_cast<ResSetAvatarInboxLimit*>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -625,14 +625,14 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatar->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar->setInboxLimit(avatar->getInboxLimit());
}
}
}
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar = avatar;
m_api->OnSetAvatarInboxLimit(R->getTrack(), R->getResult(), cachedAvatar, R->getUser());
@@ -654,13 +654,13 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_GETROOM:
{
ResGetRoom *R = static_cast<ResGetRoom *>(res);
ChatRoom *room = NULL;
ChatRoom *room = nullptr;
ChatRoomCore *roomCore = R->getRoom();
if (R->getResult() == 0 && roomCore) // if success
{
unsigned roomid = roomCore->getRoomID();
if (getRoomCore(roomid) == NULL)
if (getRoomCore(roomid) == nullptr)
{
// we need to cache this room first
cacheRoom(roomCore);
@@ -708,8 +708,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
{
ResCreateRoom *R = static_cast<ResCreateRoom *>(res);
ChatRoom *room = NULL;
ChatRoomCore* roomCore = NULL;
ChatRoom *room = nullptr;
ChatRoomCore* roomCore = nullptr;
if (R->getResult() == 0) // if success
{
@@ -939,7 +939,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
else if (!room && !roomCore)
{
// we didn't have room cached, and we didn't get one to cache,
// thus we'll have trouble giving a callback with a NULL pointer.
// thus we'll have trouble giving a callback with a nullptr pointer.
_chatdebug_("ChatAPI:BadData: RESPONSE_ENTERROOM: avatar=%p, room=%p , roomCore=%p\n", avatar, room, roomCore);
}
}
@@ -1175,8 +1175,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_FINDAVATARBYUID:
{
ResFindAvatarByUID *R = static_cast<ResFindAvatarByUID *>(res);
ChatAvatar **avatarMatches = NULL;
ChatAvatarCore **avatarCoreMatches = NULL;
ChatAvatar **avatarMatches = nullptr;
ChatAvatarCore **avatarCoreMatches = nullptr;
unsigned numAvatarsOnline = R->getNumAvatarsOnline();
@@ -1374,7 +1374,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// duplicate login from this API, then effectively
// our API must consider him logged out because he's now
// no longer logged in to his AID controller.
m_api->OnLogoutAvatar(0, 0, avatar, NULL);
m_api->OnLogoutAvatar(0, 0, avatar, nullptr);
}
}
@@ -1476,7 +1476,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_GETAVATARKEYWORDS:
{
ResGetAvatarKeywords *R = static_cast<ResGetAvatarKeywords *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
@@ -1494,7 +1494,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SETAVATARKEYWORDS:
{
ResSetAvatarKeywords *R = static_cast<ResSetAvatarKeywords *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getAvatarID());
@@ -1510,8 +1510,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SEARCHAVATARKEYWORDS:
{
ResSearchAvatarKeywords *R = static_cast<ResSearchAvatarKeywords *>(res);
ChatAvatar **avatarMatches = NULL;
ChatAvatarCore **avatarCoreMatches = NULL;
ChatAvatar **avatarMatches = nullptr;
ChatAvatarCore **avatarCoreMatches = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
@@ -1530,7 +1530,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_CONFIRMFRIEND:
{
ResFriendConfirm *R = static_cast<ResFriendConfirm *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getAvatarID());
@@ -1546,7 +1546,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_CONFIRMFRIEND_RECIPROCATE:
{
ResFriendConfirmReciprocate *R = static_cast<ResFriendConfirmReciprocate *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getAvatarID());
@@ -1616,7 +1616,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_ADDSNOOPAVATAR:
{
ResAddSnoopAvatar *R = static_cast<ResAddSnoopAvatar *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getSrcAvatarID());
@@ -1632,7 +1632,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_REMOVESNOOPAVATAR:
{
ResRemoveSnoopAvatar *R = static_cast<ResRemoveSnoopAvatar *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getSrcAvatarID());
@@ -1648,7 +1648,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_ADDSNOOPROOM:
{
ResAddSnoopRoom *R = static_cast<ResAddSnoopRoom *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getSrcAvatarID());
@@ -1664,7 +1664,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_REMOVESNOOPROOM:
{
ResRemoveSnoopRoom *R = static_cast<ResRemoveSnoopRoom *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getSrcAvatarID());
@@ -1680,7 +1680,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_GETSNOOPLIST:
{
ResGetSnoopList *R = static_cast<ResGetSnoopList *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getSrcAvatarID());
@@ -1691,8 +1691,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
_chatdebug_("ChatAPI:BadData: RESPONSE_REMOVESNOOPROOM: avatar=%p\n", avatar);
}
AvatarSnoopPair **avatarList = NULL;
ChatUnicodeString **roomList = NULL;
AvatarSnoopPair **avatarList = nullptr;
ChatUnicodeString **roomList = nullptr;
unsigned numAvatars = R->getAvatarSnoopListLength();
unsigned numRooms = R->getRoomSnoopListLength();
@@ -1763,7 +1763,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatAvatar *destAvatar = getAvatar(M.getDestList()[i]);
if (!destAvatar)
{
_chatdebug_("ChatAPI:BadData: MESSAGE_ROOMMESSAGE: destAvatar[%i]=NULL\n", i);
_chatdebug_("ChatAPI:BadData: MESSAGE_ROOMMESSAGE: destAvatar[%i]=nullptr\n", i);
continue;
}
m_api->OnReceiveRoomMessage(srcAvatar, destAvatar, destRoom, ChatUnicodeString(M.getMsg().data(), M.getMsg().size()), ChatUnicodeString(M.getOOB().data(), M.getOOB().size()));
@@ -1797,7 +1797,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatAvatar *destAvatar = getAvatar(M.getDestList()[i]);
if (!destAvatar)
{
_chatdebug_("ChatAPI:BadData: MESSAGE_BROADCASTMESSAGE: destAvatar[%i]=NULL\n", i);
_chatdebug_("ChatAPI:BadData: MESSAGE_BROADCASTMESSAGE: destAvatar[%i]=nullptr\n", i);
continue;
}
m_api->OnReceiveBroadcastMessage(srcAvatar, ChatUnicodeString(M.getSrcAddress().data(), M.getSrcAddress().size()), destAvatar, ChatUnicodeString(M.getMsg().data(), M.getMsg().size()), ChatUnicodeString(M.getOOB().data(), M.getOOB().size()));
@@ -1877,7 +1877,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatRoomCore *destRoomCore = getRoomCore(M.getRoomID());
if (!destRoomCore) {
_chatdebug_("ChatAPI:destroomCore is null!");
_chatdebug_("ChatAPI:destroomCore is nullptr!");
break;
}
@@ -1889,7 +1889,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatAvatar *destAvatar = M.getDestAvatar()->getNewChatAvatar();
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
ChatAvatarCore *kickedAvatar = destRoomCore ? destRoomCore->removeAvatar(destAvatar->getAvatarID()) : NULL;
ChatAvatarCore *kickedAvatar = destRoomCore ? destRoomCore->removeAvatar(destAvatar->getAvatarID()) : nullptr;
ChatRoom *destRoom = getRoom(M.getRoomID());
if (!srcAvatar || !destAvatar || !kickedAvatar || !destRoom)
@@ -2439,12 +2439,12 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
if (!srcAvatar)
{
_chatdebug_("ChatAPI:BadData: MESSAGE_ENTERROOM: srcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_ENTERROOM: srcAvatar=nullptr\n");
delete M.getSrcAvatar();
break;
}
bool isLocalAvatar = (getAvatar(srcAvatar->getAvatarID()) != NULL);
bool isLocalAvatar = (getAvatar(srcAvatar->getAvatarID()) != nullptr);
if(!destRoomCore->addAvatar(M.getSrcAvatar(),isLocalAvatar))
{
delete M.getSrcAvatar();
@@ -2492,10 +2492,10 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
if (destRoomCore)
{
ChatRoom *destRoom = getRoom(M.getRoomID());
ChatAvatar *srcAvatar = NULL;
ChatAvatar *srcAvatar = nullptr;
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_DESTROYROOM: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_DESTROYROOM: M.getSrcAvatar=nullptr\n");
}
else
{
@@ -2527,7 +2527,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatRoomCore *destRoomCore = getRoomCore(M.getRoomID());
if (!destRoomCore)
{
_chatdebug_("ChatAPI:BadData: MESSAGE_SETROOMPARAMS: destRoomCore=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_SETROOMPARAMS: destRoomCore=nullptr\n");
break;
}
@@ -2544,7 +2544,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_SETROOMPARAMS: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_SETROOMPARAMS: M.getSrcAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
@@ -2686,7 +2686,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
{
MAddAdmin M(iter);
ChatRoomCore *destRoomCore = getRoomCore(M.getRoomID());
if (destRoomCore && (destRoomCore->addAdministrator(M.getAvatar()) == NULL))
if (destRoomCore && (destRoomCore->addAdministrator(M.getAvatar()) == nullptr))
{
delete (M.getAvatar());
}
@@ -2696,7 +2696,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
{
MRemoveAdmin M(iter);
ChatRoomCore *destRoomCore = getRoomCore(M.getRoomID());
ChatAvatarCore *admin = NULL;
ChatAvatarCore *admin = nullptr;
if (destRoomCore)
admin = destRoomCore->removeAdministrator(M.getAvatarID());
delete admin;
@@ -2707,7 +2707,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
MFriendConfirmRequest M(iter);
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMREQUEST: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMREQUEST: M.getSrcAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
@@ -2730,7 +2730,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRESPONSE: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRESPONSE: M.getSrcAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
@@ -2752,7 +2752,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
MFriendConfirmReciprocateRequest M(iter);
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRECIPROCATE_REQUEST: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRECIPROCATE_REQUEST: M.getSrcAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
@@ -2775,7 +2775,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRECIPROCATE_RESPONSE: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRECIPROCATE_RESPONSE: M.getSrcAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
@@ -2799,7 +2799,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatRoomCore *destRoomCore = getRoomCore(M.getDestRoomID());
if (!destRoomCore)
{
_chatdebug_("ChatAPI:BadData: MESSAGE_CHANGEROOMOWNER: destRoomCore=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_CHANGEROOMOWNER: destRoomCore=nullptr\n");
break;
}
@@ -2822,7 +2822,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
if (!M.getRequestorAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_REQUESTROOMENTRY: M.getRequestorAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_REQUESTROOMENTRY: M.getRequestorAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getRequestorAvatar()->getNewChatAvatar();
@@ -3025,7 +3025,7 @@ void ChatAPICore::processAPI()
}
// if we've been disconnected for at least a minute...
else if (!m_connected &&
time(NULL) - m_timeSinceLastDisconnect >= 60)
time(nullptr) - m_timeSinceLastDisconnect >= 60)
{
if (m_setToRegistrar)
{
@@ -3043,7 +3043,7 @@ void ChatAPICore::processAPI()
m_setToRegistrar = true;
}
m_timeSinceLastDisconnect = time(NULL);
m_timeSinceLastDisconnect = time(nullptr);
}
@@ -3072,7 +3072,7 @@ void ChatAPICore::OnConnect(const char *host, short port)
res->setTrack(m_currTrack);
m_currTrack++;
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -3103,7 +3103,7 @@ void ChatAPICore::OnConnect(const char *host, short port)
res->setTrack(m_currTrack);
m_currTrack++;
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -3147,7 +3147,7 @@ void ChatAPICore::OnDisconnect(const char *host, short port)
// stop processing immediately
suspendProcessing();
m_timeSinceLastDisconnect = time(NULL);
m_timeSinceLastDisconnect = time(nullptr);
// determine who we disconnected from and take appropriate action
if (strcmp(host, m_registrarHost.c_str()) == 0 &&
@@ -3214,7 +3214,7 @@ void ChatAPICore::failoverReloginOneAvatar(ChatAvatarCore * avatarCore)
res->setTrack(m_currTrack);
m_currTrack++;
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -3241,7 +3241,7 @@ void ChatAPICore::failoverRecreateRooms()
{
// first build multimap of rooms keyed by their node level (ascending order is default).
multimap<unsigned, ChatRoomCore *> levelMap;
ChatRoomCore *roomCore = NULL;
ChatRoomCore *roomCore = nullptr;
for (roomIter = m_roomCoreCache.begin(); roomIter != m_roomCoreCache.end(); ++roomIter)
{
roomCore = (*roomIter).second;
@@ -3268,7 +3268,7 @@ void ChatAPICore::failoverRecreateRooms()
res->setTrack(m_currTrack);
m_currTrack++;
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -3296,7 +3296,7 @@ void ChatAPICore::failoverRecreateRooms()
ChatAvatar *ChatAPICore::getAvatar(const ChatUnicodeString &avatarName, const ChatUnicodeString &avatarAddress)
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
map<unsigned, ChatAvatar *>::iterator iter = m_avatarCache.begin();
@@ -3317,7 +3317,7 @@ ChatAvatar *ChatAPICore::getAvatar(const ChatUnicodeString &avatarName, const Ch
ChatRoom *ChatAPICore::getRoom(const ChatUnicodeString &roomAddress)
{
ChatRoom *returnVal = NULL;
ChatRoom *returnVal = nullptr;
map<unsigned, ChatRoom *>::iterator iter = m_roomCache.begin();
@@ -43,7 +43,7 @@ ChatUnicodeString::ChatUnicodeString(const std::string& nSrc)
ChatUnicodeString::ChatUnicodeString(const char *nStrSrc)
{
if (nStrSrc==NULL)
if (nStrSrc==nullptr)
{
m_wideString = getEmptyString();
m_cString = wideToNarrow(m_wideString);
@@ -7,7 +7,7 @@ namespace ChatSystem
using namespace Base;
using namespace Plat_Unicode;
ChatFriendStatusCore::ChatFriendStatusCore()
: m_interface(NULL),
: m_interface(nullptr),
m_status(0)
{
}
@@ -31,7 +31,7 @@ ChatFriendStatusCore::~ChatFriendStatusCore()
}
ChatFriendStatus::ChatFriendStatus()
: m_core(NULL)
: m_core(nullptr)
{
}
@@ -7,7 +7,7 @@ namespace ChatSystem
using namespace Plat_Unicode;
ChatIgnoreStatus::ChatIgnoreStatus()
: m_core(NULL)
: m_core(nullptr)
{
}
@@ -16,7 +16,7 @@ namespace ChatSystem
}
ChatIgnoreStatusCore::ChatIgnoreStatusCore()
: m_interface(NULL)
: m_interface(nullptr)
{
}
@@ -581,7 +581,7 @@ unsigned RoomSummary::getRoomMaxSize() const
ChatRoom::ChatRoom()
{
m_core = NULL;
m_core = nullptr;
}
ChatRoom::ChatRoom(ChatRoomCore *core)
@@ -189,7 +189,7 @@ ChatRoomCore::~ChatRoomCore()
ChatAvatarCore *ChatRoomCore::getAvatarCore(unsigned avatarID)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
map<unsigned, ChatAvatarCore *>::iterator iterCore = m_inroomAvatarsCore.find(avatarID);
@@ -202,7 +202,7 @@ ChatAvatarCore *ChatRoomCore::getAvatarCore(unsigned avatarID)
ChatAvatar *ChatRoomCore::getAvatar(unsigned avatarID)
{
ChatAvatar *returnAvatar = NULL;
ChatAvatar *returnAvatar = nullptr;
map<unsigned, ChatAvatar *>::iterator iter = m_inroomAvatars.find(avatarID);
@@ -215,7 +215,7 @@ ChatAvatar *ChatRoomCore::getAvatar(unsigned avatarID)
ChatAvatarCore *ChatRoomCore::getModeratorCore(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_moderatorAvatarsCore.begin();
@@ -238,7 +238,7 @@ ChatAvatarCore *ChatRoomCore::getModeratorCore(const Plat_Unicode::String &name,
ChatAvatar *ChatRoomCore::getModerator(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatar *returnAvatar = NULL;
ChatAvatar *returnAvatar = nullptr;
set<ChatAvatar *>::iterator iter = m_moderatorAvatars.begin();
@@ -263,7 +263,7 @@ ChatAvatar *ChatRoomCore::getModerator(const Plat_Unicode::String &name, const P
ChatAvatarCore *ChatRoomCore::getBannedCore(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_banAvatarsCore.begin();
@@ -286,7 +286,7 @@ ChatAvatarCore *ChatRoomCore::getBannedCore(const Plat_Unicode::String &name, co
ChatAvatar *ChatRoomCore::getBanned(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatar *returnAvatar = NULL;
ChatAvatar *returnAvatar = nullptr;
set<ChatAvatar *>::iterator iter = m_banAvatars.begin();
@@ -311,7 +311,7 @@ ChatAvatar *ChatRoomCore::getBanned(const Plat_Unicode::String &name, const Plat
ChatAvatarCore *ChatRoomCore::getInvitedCore(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_inviteAvatarsCore.begin();
@@ -334,7 +334,7 @@ ChatAvatarCore *ChatRoomCore::getInvitedCore(const Plat_Unicode::String &name, c
ChatAvatar *ChatRoomCore::getInvited(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatar *returnAvatar = NULL;
ChatAvatar *returnAvatar = nullptr;
set<ChatAvatar *>::iterator iter = m_inviteAvatars.begin();
@@ -359,7 +359,7 @@ ChatAvatar *ChatRoomCore::getInvited(const Plat_Unicode::String &name, const Pla
ChatAvatarCore *ChatRoomCore::addAvatar(ChatAvatarCore *newAvatar, bool local)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -394,7 +394,7 @@ void ChatRoomCore::addLocalAvatar(unsigned avatarID)
ChatAvatarCore *ChatRoomCore::removeAvatar(unsigned avatarID)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
map<unsigned, ChatAvatarCore *>::iterator iterCore = m_inroomAvatarsCore.find(avatarID);
@@ -422,7 +422,7 @@ ChatAvatarCore *ChatRoomCore::removeAvatar(unsigned avatarID)
ChatAvatarCore *ChatRoomCore::addBan(ChatAvatarCore *newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -446,7 +446,7 @@ ChatAvatarCore *ChatRoomCore::addBan(ChatAvatarCore *newAvatar)
ChatAvatarCore *ChatRoomCore::removeBan(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_banAvatarsCore.begin();
@@ -494,7 +494,7 @@ ChatAvatarCore *ChatRoomCore::removeBan(const Plat_Unicode::String &name, const
ChatAvatarCore *ChatRoomCore::addAdministrator(ChatAvatarCore *newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -518,7 +518,7 @@ ChatAvatarCore *ChatRoomCore::addAdministrator(ChatAvatarCore *newAvatar)
ChatAvatarCore *ChatRoomCore::removeAdministrator(unsigned avatarID)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
map<unsigned, ChatAvatarCore *>::iterator iterCore = m_adminAvatarsCore.find(avatarID);
@@ -541,7 +541,7 @@ ChatAvatarCore *ChatRoomCore::removeAdministrator(unsigned avatarID)
ChatAvatarCore *ChatRoomCore::addModerator(ChatAvatarCore *newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -565,7 +565,7 @@ ChatAvatarCore *ChatRoomCore::addModerator(ChatAvatarCore *newAvatar)
ChatAvatarCore *ChatRoomCore::removeModerator(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_moderatorAvatarsCore.begin();
@@ -613,7 +613,7 @@ ChatAvatarCore *ChatRoomCore::removeModerator(const Plat_Unicode::String &name,
ChatAvatarCore *ChatRoomCore::addTempModerator(ChatAvatarCore *newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -637,7 +637,7 @@ ChatAvatarCore *ChatRoomCore::addTempModerator(ChatAvatarCore *newAvatar)
ChatAvatarCore *ChatRoomCore::removeTempModerator(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_tempModeratorAvatarsCore.begin();
@@ -685,7 +685,7 @@ ChatAvatarCore *ChatRoomCore::removeTempModerator(const Plat_Unicode::String &na
ChatAvatarCore *ChatRoomCore::addInvite(ChatAvatarCore* newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -709,7 +709,7 @@ ChatAvatarCore *ChatRoomCore::addInvite(ChatAvatarCore* newAvatar)
ChatAvatarCore *ChatRoomCore::removeInvite(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_inviteAvatarsCore.begin();
@@ -757,7 +757,7 @@ ChatAvatarCore *ChatRoomCore::removeInvite(const Plat_Unicode::String &name, con
ChatAvatarCore *ChatRoomCore::addVoice(ChatAvatarCore* newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -781,7 +781,7 @@ ChatAvatarCore *ChatRoomCore::addVoice(ChatAvatarCore* newAvatar)
ChatAvatarCore *ChatRoomCore::removeVoice(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_voiceAvatarsCore.begin();
@@ -1053,7 +1053,7 @@ void ChatRoomCore::serializeWithLocalAvatarsOnly(Base::ByteStream &msg)
for (avatarIter = m_inroomAvatarsCore.begin(); avatarIter != m_inroomAvatarsCore.end(); ++avatarIter)
{
// include only the avatars that are on this API
if ( this->getAvatar((*avatarIter).second->getAvatarID()) != NULL )
if ( this->getAvatar((*avatarIter).second->getAvatarID()) != nullptr )
{
avatarsToSend.insert((*avatarIter).second);
}
@@ -21,7 +21,7 @@ namespace ChatSystem
MRoomMessage::MRoomMessage(ByteStream::ReadIterator &iter)
: GenericMessage(MESSAGE_ROOMMESSAGE),
m_destList(NULL),
m_destList(nullptr),
m_srcAvatar(iter),
m_messageID(0)
{
@@ -45,13 +45,13 @@ namespace ChatSystem
MRoomMessage::~MRoomMessage()
{
delete[] m_destList;
m_destList = NULL;
m_destList = nullptr;
}
MBroadcastMessage::MBroadcastMessage(ByteStream::ReadIterator &iter)
: GenericMessage(MESSAGE_BROADCASTMESSAGE),
m_srcAvatar(iter),
m_destList(NULL)
m_destList(nullptr)
{
ASSERT_VALID_STRING_LENGTH(get(iter, m_srcAddress));
get(iter, m_listLength);
@@ -68,7 +68,7 @@ namespace ChatSystem
MBroadcastMessage::~MBroadcastMessage()
{
delete[] m_destList;
m_destList = NULL;
m_destList = nullptr;
}
MFilterMessage::MFilterMessage(ByteStream::ReadIterator &iter)
@@ -8,7 +8,7 @@ using namespace Base;
using namespace Plat_Unicode;
PersistentHeader::PersistentHeader()
: m_core(NULL)
: m_core(nullptr)
{
}
@@ -66,7 +66,7 @@ PersistentHeaderCore::PersistentHeaderCore()
m_avatarID(0),
m_sentTime(0),
m_status(0),
m_interface(NULL)
m_interface(nullptr)
{
}
@@ -127,7 +127,7 @@ void RGetAvatarKeywords::pack(ByteStream &msg)
RSearchAvatarKeywords::RSearchAvatarKeywords(const ChatUnicodeString &nodeAddress, const ChatUnicodeString *keywordsList, unsigned keywordsLength)
: GenericRequest(REQUEST_SEARCHAVATARKEYWORDS),
m_keywordsLength(keywordsLength),
m_keywordsList(NULL)
m_keywordsList(nullptr)
{
m_nodeAddress.assign(nodeAddress.string_data);
m_keywordsList = new String[keywordsLength];
@@ -898,7 +898,7 @@ m_srcAddress(srcAddress.string_data, srcAddress.string_length),
m_destRoomAddress(destRoomAddress.string_data, destRoomAddress.string_length)
{
// we take in a const RoomParams, so make our own and guarantee
// null-terminated char buffers.
// nullptr-terminated char buffers.
m_newRoomName.assign(params->getRoomName().string_data, params->getRoomName().string_length);
m_newRoomTopic.assign(params->getRoomTopic().string_data, params->getRoomTopic().string_length);
m_newRoomPassword.assign(params->getRoomPassword().string_data, params->getRoomPassword().string_length);
@@ -20,7 +20,7 @@ using namespace Plat_Unicode;
ResLoginAvatar::ResLoginAvatar(void *user, int avatarLoginPriority)
: GenericResponse(RESPONSE_LOGINAVATAR, CHATRESULT_TIMEOUT, user),
m_avatar(NULL),
m_avatar(nullptr),
m_submittedPriority(avatarLoginPriority),
m_requiredPriority(INT_MAX)
{
@@ -63,7 +63,7 @@ void ResLoginAvatar::unpack(ByteStream::ReadIterator &iter)
ResTemporaryAvatar::ResTemporaryAvatar(void *user)
: GenericResponse(RESPONSE_TEMPORARYAVATAR, CHATRESULT_TIMEOUT, user)
, m_avatar(NULL)
, m_avatar(nullptr)
{
}
@@ -110,7 +110,7 @@ void ResDestroyAvatar::unpack(ByteStream::ReadIterator &iter)
ResGetAvatar::ResGetAvatar(void *user)
: GenericResponse(RESPONSE_GETAVATAR, CHATRESULT_TIMEOUT, user),
m_avatar(NULL)
m_avatar(nullptr)
{
}
@@ -144,7 +144,7 @@ void ResGetAvatar::unpack(ByteStream::ReadIterator &iter)
ResGetAnyAvatar::ResGetAnyAvatar(void* user)
: GenericResponse( RESPONSE_GETANYAVATAR, CHATRESULT_TIMEOUT, user )
, m_avatar( NULL )
, m_avatar( nullptr )
{
}
@@ -181,8 +181,8 @@ void ResGetAnyAvatar::unpack(Base::ByteStream::ReadIterator& iter)
ResAvatarList::ResAvatarList(void *user)
: GenericResponse(RESPONSE_AVATARLIST, CHATRESULT_TIMEOUT, user)
, m_listLength(0)
, m_avatarList(NULL)
, m_cores(NULL)
, m_avatarList(nullptr)
, m_cores(nullptr)
{
}
@@ -214,7 +214,7 @@ void ResAvatarList::unpack(ByteStream::ReadIterator &iter)
ResSetAvatarAttributes::ResSetAvatarAttributes(void *user)
: GenericResponse(RESPONSE_SETAVATARATTRIBUTES, CHATRESULT_TIMEOUT, user),
m_avatar(NULL)
m_avatar(nullptr)
{
}
@@ -248,7 +248,7 @@ void ResSetAvatarAttributes::unpack(ByteStream::ReadIterator &iter)
ResSetAvatarStatusMessage::ResSetAvatarStatusMessage(void *user)
: GenericResponse(RESPONSE_SETSTATUSMESSAGE, CHATRESULT_TIMEOUT, user),
m_avatar(NULL)
m_avatar(nullptr)
{
}
@@ -285,7 +285,7 @@ void ResSetAvatarStatusMessage::unpack(ByteStream::ReadIterator &iter)
ResSetAvatarForwardingEmail::ResSetAvatarForwardingEmail(void *user)
: GenericResponse(RESPONSE_SETAVATAREMAIL, CHATRESULT_TIMEOUT, user),
m_avatar(NULL)
m_avatar(nullptr)
{
}
@@ -312,7 +312,7 @@ void ResSetAvatarForwardingEmail::unpack(ByteStream::ReadIterator &iter)
ResSetAvatarInboxLimit::ResSetAvatarInboxLimit(void *user)
: GenericResponse(RESPONSE_SETAVATARINBOXLIMIT, CHATRESULT_TIMEOUT, user),
m_avatar(NULL)
m_avatar(nullptr)
{
}
@@ -340,7 +340,7 @@ void ResSetAvatarInboxLimit::unpack(ByteStream::ReadIterator &iter)
ResSearchAvatarKeywords::ResSearchAvatarKeywords(void *user)
: GenericResponse(RESPONSE_SETAVATARKEYWORDS, CHATRESULT_TIMEOUT, user),
m_numMatches(0),
m_avatarMatches(NULL)
m_avatarMatches(nullptr)
{
}
@@ -388,8 +388,8 @@ void ResSetAvatarKeywords::unpack(ByteStream::ReadIterator &iter)
ResGetAvatarKeywords::ResGetAvatarKeywords(void *user, unsigned avatarID)
: GenericResponse(RESPONSE_GETAVATARKEYWORDS, CHATRESULT_TIMEOUT, user),
m_avatarID(avatarID),
m_keywordList(NULL),
m_chatStrList(NULL)
m_keywordList(nullptr),
m_chatStrList(nullptr)
{
}
@@ -420,7 +420,7 @@ void ResGetAvatarKeywords::unpack(ByteStream::ReadIterator &iter)
ResGetRoom::ResGetRoom(void *user)
: GenericResponse(RESPONSE_GETROOM, CHATRESULT_TIMEOUT, user),
m_room(NULL),
m_room(nullptr),
m_numExtraRooms(0)
{
}
@@ -448,7 +448,7 @@ void ResGetRoom::unpack(ByteStream::ReadIterator &iter)
ResCreateRoom::ResCreateRoom(void *user, unsigned avatarID)
: GenericResponse(RESPONSE_CREATEROOM, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(avatarID),
m_room(NULL),
m_room(nullptr),
m_numExtraRooms(0)
{
}
@@ -637,8 +637,8 @@ ResFriendStatus::ResFriendStatus(void *user, unsigned avatarID)
: GenericResponse(RESPONSE_FRIENDSTATUS, CHATRESULT_TIMEOUT, user),
m_avatarID(avatarID),
m_listLength(0),
m_friendList(NULL),
m_cores(NULL)
m_friendList(nullptr),
m_cores(nullptr)
{
}
@@ -704,8 +704,8 @@ ResIgnoreStatus::ResIgnoreStatus(void *user, unsigned avatarID)
: GenericResponse(RESPONSE_IGNORESTATUS, CHATRESULT_TIMEOUT, user),
m_avatarID(avatarID),
m_listLength(0),
m_ignoreList(NULL),
m_cores(NULL)
m_ignoreList(nullptr),
m_cores(nullptr)
{
}
@@ -740,7 +740,7 @@ ResEnterRoom::ResEnterRoom(void *user, unsigned avatarID, const ChatUnicodeStrin
m_avatarID(avatarID),
m_destAddress(destAddress.string_data, destAddress.string_length),
m_gotRoomObj(false),
m_room(NULL),
m_room(nullptr),
m_numExtraRooms(0)
{
}
@@ -1012,7 +1012,7 @@ void ResChangeRoomOwner::unpack(ByteStream::ReadIterator &iter)
ResGetRoomSummaries::ResGetRoomSummaries(void *user)
: GenericResponse(RESPONSE_GETROOMSUMMARIES, CHATRESULT_TIMEOUT, user),
m_numRooms(0),
m_roomSummaries(NULL)
m_roomSummaries(nullptr)
{
}
@@ -1132,8 +1132,8 @@ ResGetPersistentMessage::ResGetPersistentMessage(void *user, unsigned srcAvatarI
: GenericResponse(RESPONSE_GETPERSISTENTMESSAGE, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(srcAvatarID),
m_messageID(messageID),
m_core(NULL),
m_header(NULL)
m_core(nullptr),
m_header(nullptr)
{
}
@@ -1167,7 +1167,7 @@ void ResGetPersistentMessage::unpack(ByteStream::ReadIterator &iter)
ResGetMultiplePersistentMessages::ResGetMultiplePersistentMessages(void *user, unsigned srcAvatarID)
: GenericResponse(RESPONSE_GETMULTIPLEPERSISTENTMESSAGES, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(srcAvatarID),
m_messages(NULL)
m_messages(nullptr)
{
}
@@ -1217,8 +1217,8 @@ ResGetPersistentHeaders::ResGetPersistentHeaders(void *user, unsigned srcAvatarI
: GenericResponse(RESPONSE_GETPERSISTENTHEADERS, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(srcAvatarID),
m_listLength(0),
m_headers(NULL),
m_cores(NULL)
m_headers(nullptr),
m_cores(nullptr)
{
}
@@ -1263,8 +1263,8 @@ ResGetPartialPersistentHeaders::ResGetPartialPersistentHeaders(void *user, unsig
: GenericResponse(RESPONSE_PARTIALPERSISTENTHEADERS, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(srcAvatarID),
m_listLength(0),
m_headers(NULL),
m_cores(NULL)
m_headers(nullptr),
m_cores(nullptr)
{
}
@@ -1396,7 +1396,7 @@ void ResUnregisterRoom::unpack(ByteStream::ReadIterator &iter)
}
ResFailoverReloginAvatar::ResFailoverReloginAvatar(unsigned avatarID)
: GenericResponse(RESPONSE_FAILOVER_RELOGINAVATAR, CHATRESULT_TIMEOUT, NULL),
: GenericResponse(RESPONSE_FAILOVER_RELOGINAVATAR, CHATRESULT_TIMEOUT, nullptr),
m_avatarID(avatarID)
{
}
@@ -1414,9 +1414,9 @@ void ResFailoverReloginAvatar::unpack(ByteStream::ReadIterator &iter)
}
ResFailoverRecreateRoom::ResFailoverRecreateRoom(unsigned roomID, bool forced)
: GenericResponse(RESPONSE_FAILOVER_RECREATEROOM, CHATRESULT_TIMEOUT, NULL),
: GenericResponse(RESPONSE_FAILOVER_RECREATEROOM, CHATRESULT_TIMEOUT, nullptr),
m_roomID(roomID),
m_room(NULL),
m_room(nullptr),
m_forced(forced)
{
}
@@ -1478,7 +1478,7 @@ void ResGetFanClubHandle::unpack(ByteStream::ReadIterator &iter)
ResFindAvatarByUID::ResFindAvatarByUID(void *user)
: GenericResponse(RESPONSE_FINDAVATARBYUID, CHATRESULT_TIMEOUT, user),
m_numAvatarsOnline(0),
m_avatars(NULL)
m_avatars(nullptr)
{
}
@@ -1512,7 +1512,7 @@ void ResFindAvatarByUID::unpack(ByteStream::ReadIterator &iter)
}
ResRegistrarGetChatServer::ResRegistrarGetChatServer()
: GenericResponse(RESPONSE_REGISTRAR_GETCHATSERVER, CHATRESULT_TIMEOUT, NULL)
: GenericResponse(RESPONSE_REGISTRAR_GETCHATSERVER, CHATRESULT_TIMEOUT, nullptr)
{
}
@@ -1527,7 +1527,7 @@ void ResRegistrarGetChatServer::unpack(ByteStream::ReadIterator &iter)
}
ResSendApiVersion::ResSendApiVersion()
: GenericResponse(RESPONSE_SETAPIVERSION, CHATRESULT_TIMEOUT, NULL)
: GenericResponse(RESPONSE_SETAPIVERSION, CHATRESULT_TIMEOUT, nullptr)
{
}
@@ -1600,8 +1600,8 @@ void ResRemoveSnoopRoom::unpack(ByteStream::ReadIterator &iter)
ResGetSnoopList::ResGetSnoopList(void *user, unsigned srcAvatarID)
: GenericResponse(RESPONSE_GETSNOOPLIST, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(srcAvatarID),
m_avatarSnoops(NULL),
m_roomSnoops(NULL)
m_avatarSnoops(nullptr),
m_roomSnoops(nullptr)
{
}
@@ -107,7 +107,7 @@ namespace Base
ByteStream::ByteStream() :
allocatedSize(0),
beginReadIterator(),
data(NULL),
data(nullptr),
size(0),
lastPutSize(0)
{
@@ -224,7 +224,7 @@ namespace Base
if(data->size < allocatedSize)
{
unsigned char * tmp = new unsigned char[newSize];
if(data->buffer != NULL)
if(data->buffer != nullptr)
memcpy(tmp, data->buffer, size);
delete[] data->buffer;
data->buffer = tmp;
@@ -35,7 +35,7 @@ bool CAutoLog::Open(const char * filename)
//-------------------------------------
{
if( NULL == filename)
if( nullptr == filename)
return false;
if (pFilename)
@@ -45,13 +45,13 @@ bool CAutoLog::Open(const char * filename)
// Sanitize slashes
char *ptr;
while ((ptr = strchr(pFilename,WRONGSLASH)) != NULL)
while ((ptr = strchr(pFilename,WRONGSLASH)) != nullptr)
*ptr = SLASHCHAR[0];
char strPath[1024];
strcpy(strPath,pFilename);
ptr = strrchr(strPath, SLASHCHAR[0]);
if (ptr != NULL)
if (ptr != nullptr)
{
*ptr = 0;
@@ -59,11 +59,11 @@ bool CAutoLog::Open(const char * filename)
char curdir[128];
// remember current directory
if( getcwd(curdir,sizeof(curdir)) == NULL )
if( getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
@@ -74,7 +74,7 @@ bool CAutoLog::Open(const char * filename)
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
}
@@ -94,7 +94,7 @@ bool CAutoLog::Open(const char * filename)
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
}
@@ -103,7 +103,7 @@ bool CAutoLog::Open(const char * filename)
pFile = fopen(pFilename,"a+");
if( pFile == NULL || pFile == (FILE *)-1)
if( pFile == nullptr || pFile == (FILE *)-1)
{
//fprintf(stderr,"CAutoLog::Open failed to open log file: %s\n",pFilename);
Close();
@@ -123,7 +123,7 @@ bool CAutoLog::Open(const char * filename)
void CAutoLog::Close(void)
//-------------------------------------
{
if( pFile != (FILE *)-1 && pFile != NULL)
if( pFile != (FILE *)-1 && pFile != nullptr)
{
fclose(pFile);
}
@@ -131,7 +131,7 @@ void CAutoLog::Close(void)
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
}
//-------------------------------------
@@ -194,7 +194,7 @@ void CAutoLog::LogDebug(char * format, ...)
void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == NULL)
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Log called with no file open!\n");
return;
@@ -250,7 +250,7 @@ void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
void CAutoLog::Archive(void)
//-------------------------------------
{
if( pFile == (FILE *)-1 || pFile == NULL)
if( pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Archive called with no file open!\n");
return;
@@ -281,7 +281,7 @@ void CAutoLog::Archive(void)
strcpy(strCurrent,pFilename);
pCurrent = strrchr(strCurrent, SLASHCHAR[0]);
if (pCurrent != NULL)
if (pCurrent != nullptr)
*pCurrent = 0;
else
sprintf(strCurrent,".");
@@ -290,7 +290,7 @@ void CAutoLog::Archive(void)
#ifdef WIN32
// remember current directory
if( getcwd(curdir,sizeof(curdir)) == NULL )
if( getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
return; // error, can't proceed
@@ -324,7 +324,7 @@ void CAutoLog::Archive(void)
#endif
pCurrent = strrchr(pFilename, SLASHCHAR[0]);
if (pCurrent == NULL)
if (pCurrent == nullptr)
pCurrent = pFilename;
else
pCurrent++;
@@ -92,14 +92,14 @@ namespace Base
//-------------------------------------
inline CAutoLog::CAutoLog()
{
pFilename = NULL;
pFilename = nullptr;
pFile = (FILE *)-1;
}
//-------------------------------------
inline CAutoLog::CAutoLog(const char * file)
{
pFilename = NULL;
pFilename = nullptr;
pFile = (FILE *)-1;
Open(file);
}
@@ -135,7 +135,7 @@ int CCmdLine::SplitLine(int argc, char **argv)
bool CCmdLine::IsSwitch(const char *pParam)
{
if (pParam==NULL)
if (pParam==nullptr)
return false;
// switches must non-empty
@@ -204,7 +204,7 @@ StringType CCmdLine::GetSafeArgument(const char *pSwitch, int iIdx, const char *
{
StringType sRet;
if (pDefault!=NULL)
if (pDefault!=nullptr)
sRet = pDefault;
try
@@ -28,7 +28,7 @@ bool CConfig::LoadFile(char * file)
// open file
fp = fopen(file, "r");
if (fp == NULL || fp == (FILE *)-1)
if (fp == nullptr || fp == (FILE *)-1)
{
//fprintf(stderr,"Failed to open config file %s!",file);
return false;
@@ -71,21 +71,21 @@ void CConfig::UnloadFile(void)
//-----------------------------------
{
delete[] pConfig;
pConfig = NULL;
pConfig = nullptr;
}
//-----------------------------------
/// finds a key of the config in memory
// key argument is case-insensitive, but must be upper case in config file
// Returns true for success (passing NULL is a special case returned as success)
// Returns true for success (passing nullptr is a special case returned as success)
bool CConfig::FindKey(char *key)
//-----------------------------------
{
if (pConfig == NULL)
if (pConfig == nullptr)
return false;
// special case...continue with existing key
if (key == NULL)
if (key == nullptr)
return true;
// form the search key
@@ -96,12 +96,12 @@ bool CConfig::FindKey(char *key)
// find the key heading
pCursor = strstr(pConfig,strBuffer);
if (pCursor==NULL)
if (pCursor==nullptr)
return false;
// find the closing bracket of key heading
pCursor = strchr(pCursor,']');
if (pCursor==NULL)
if (pCursor==nullptr)
return false;
pCursor++;
@@ -110,7 +110,7 @@ bool CConfig::FindKey(char *key)
//-----------------------------------
/// extract a number from the config string
// pass the key to find the first number in the list, else NULL to find the next number in the list
// pass the key to find the first number in the list, else nullptr to find the next number in the list
// returns 0 if no number is found, else returns the number
long CConfig::GetLong(char *key)
//-----------------------------------
@@ -133,20 +133,20 @@ long CConfig::GetLong(char *key)
//-----------------------------------
/// extract string (in double-quotes) from the list.
// pass the key to find the first string in the list, else NULL to find the next string in the list
// returns NULL if no string found, else returns a temporary copy of the string (without quotes)
// pass the key to find the first string in the list, else nullptr to find the next string in the list
// returns nullptr if no string found, else returns a temporary copy of the string (without quotes)
char * CConfig::GetString(char *key)
//-----------------------------------
{
if (!FindKey(key))
return NULL;
return nullptr;
// look for start of string or end of key
while (*pCursor && *pCursor != '"' && *pCursor != '[')
pCursor++;
if (*(pCursor++) != '"')
return NULL;
return nullptr;
// until closing quote
int c = 0;
@@ -160,7 +160,7 @@ char * CConfig::GetString(char *key)
}
}
return NULL;
return nullptr;
}
+12 -12
View File
@@ -10,7 +10,7 @@
; list of strings, with code example
# config.FindKey("NUMBERS");
# while (number = config.GetLong(NULL))
# while (number = config.GetLong(nullptr))
# YourHandleNumber(number);
[NUMBERS] 100
200, 300 ; formatting is very flexible as long as numbers are delimited by non-numbers
@@ -23,7 +23,7 @@
; list of strings, with code example
# config.FindKey("HOSTS");
# while (string = config.GetString(NULL))
# while (string = config.GetString(nullptr))
# YourHandleString(string);
[HOSTS]
"127.0.0.1:5999"
@@ -68,16 +68,16 @@ namespace Base
// returns TRUE if key is found.
bool FindKey(char *key);
// extract string from config. If key is NULL, extract next string in list, else extract first string.
// if key was not found, returns NULL
char * GetString(char *key = NULL);
// extract string from config. If key is nullptr, extract next string in list, else extract first string.
// if key was not found, returns nullptr
char * GetString(char *key = nullptr);
// extract number from config. If key is NULL, extract next number in list, else extract first number.
// extract number from config. If key is nullptr, extract next number in list, else extract first number.
// if key was not found, returns 0
long GetLong(char *key = NULL); // extract number from config.
long GetLong(char *key = nullptr); // extract number from config.
// indicate if config file has been loaded
inline bool FileLoaded() { return pConfig == NULL ? false : true; }
inline bool FileLoaded() { return pConfig == nullptr ? false : true; }
private:
char * pConfig; // pointer to file memory
@@ -87,14 +87,14 @@ namespace Base
inline CConfig::CConfig()
{
pConfig = NULL;
pCursor = NULL;
pConfig = nullptr;
pCursor = nullptr;
}
inline CConfig::CConfig(char * file)
{
pConfig = NULL;
pCursor = NULL;
pConfig = nullptr;
pCursor = nullptr;
LoadFile(file);
}
@@ -120,7 +120,7 @@ Logger::Logger(const char *programName,
void Logger::LoggerInit(const char *programName)
{
char buf[1024];
FILE *logDir = NULL;
FILE *logDir = nullptr;
if (0 != (m_combinedLogType & eUseLocalFile))
{
@@ -129,13 +129,13 @@ void Logger::LoggerInit(const char *programName)
{
cmkdir(m_dirPrefix.c_str(), 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
tm now;
time_t t = time(NULL);
time_t t = time(nullptr);
LOGGER_GET_CURR_TIME(now, t);
@@ -153,7 +153,7 @@ void Logger::LoggerInit(const char *programName)
{
cmkdir(buf, 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -279,7 +279,7 @@ void Logger::addLog(const char *id, unsigned logenum, int level, unsigned size)
else
{
newLog->file = fopen(newLog->filename.c_str(), "a+");
if(newLog->file == NULL)
if(newLog->file == nullptr)
{
printf("Open file %s failed\n", newLog->filename.c_str());
}
@@ -313,7 +313,7 @@ void Logger::addLog(const char *id, unsigned logenum)
else
{
newLog->file = fopen(newLog->filename.c_str(), "a+");
if(newLog->file == NULL)
if(newLog->file == nullptr)
{
printf("Open file %s failed\n", newLog->filename.c_str());
}
@@ -368,7 +368,7 @@ void Logger::logSimple(unsigned logenum, int level, const char *message)
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
{
@@ -444,7 +444,7 @@ void Logger::logSimpleWithSys(unsigned logenum, unsigned priority, int level, co
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
@@ -514,7 +514,7 @@ void Logger::log(unsigned logenum, int level, const char *message, ...)
// ensure that the buf does not contain any '%' characters.
// prevent crash problem
char *rv;
while((rv = strchr(buf, '%')) != NULL)
while((rv = strchr(buf, '%')) != nullptr)
{
*rv = ' '; // replace with space
}
@@ -546,7 +546,7 @@ void Logger::logWithSys(unsigned logenum, unsigned priority, int level, const ch
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
@@ -604,14 +604,14 @@ void Logger::logWithSys(unsigned logenum, unsigned priority, int level, const ch
void Logger::rollDate(time_t t)
{
char buf[80];
FILE *logDir = NULL;
FILE *logDir = nullptr;
logDir = fopen(m_dirPrefix.c_str(), "r+");
if(errno == ENOENT)
{
cmkdir(m_dirPrefix.c_str(), 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -627,7 +627,7 @@ void Logger::rollDate(time_t t)
{
cmkdir(buf, 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -711,7 +711,7 @@ void Logger::rollLog(LogInfo *logInfo)
{
std::string newLogName;
char timeStampBuffer[256];
time_t t = time(NULL);
time_t t = time(nullptr);
tm now;
int r;
int nTries = 10;
@@ -34,9 +34,9 @@ namespace Base
bool commit = false;
if (!mLastSampleTime)
mLastSampleTime = time(NULL);
mLastSampleTime = time(nullptr);
if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (unsigned)time(NULL))
if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (unsigned)time(nullptr))
{
mSampleTotal++;
mAggregateTotal += value;
@@ -93,7 +93,7 @@ namespace Base
void Destroy(TYPE *object)
{
if (object == NULL)
if (object == nullptr)
return;
#ifdef USE_ALLOCATOR_MUTEX
@@ -142,7 +142,7 @@ namespace Base
void FastDestroy(TYPE *object)
{
if (object == NULL)
if (object == nullptr)
return;
object->~TYPE();
@@ -94,12 +94,12 @@ namespace ucs2
}
////////////////////////////////////////
// target string is a null-terminated C string
// target string is a nullptr-terminated C string
inline string::string(const char * copy) :
mLength(0),
mData(8,0)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!copy)
{
return;
@@ -111,12 +111,12 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *copy++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
}
////////////////////////////////////////
// target string is a C string that may or may not include null characters
// target string is a C string that may or may not include nullptr characters
inline string::string(const std::string & copy) :
mLength(copy.length()),
mData(8,0)
@@ -126,17 +126,17 @@ namespace ucs2
// (2) perform transform to copy the narrow string to our
// wide string
std::transform(copy.begin(), copy.end(), mData.begin(), NarrowToWide);
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength] = 0;
}
////////////////////////////////////////
// target string is a wide null-terminated C string
// target string is a wide nullptr-terminated C string
inline string::string(const char_type * copy) :
mLength(0),
mData(8,0)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!copy)
{
return;
@@ -148,7 +148,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *copy++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
}
@@ -169,7 +169,7 @@ namespace ucs2
inline string & string::operator=(const char * rhs)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -182,7 +182,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -195,7 +195,7 @@ namespace ucs2
// (2) perform transform to copy the narrow string to our
// wide string
std::transform(rhs.begin(), rhs.end(), mData.begin(), NarrowToWide);
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength] = 0;
return *this;
}
@@ -203,7 +203,7 @@ namespace ucs2
inline string & string::operator=(const char_type * rhs)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -216,7 +216,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -235,7 +235,7 @@ namespace ucs2
inline string & string::operator+=(const char * rhs)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -247,7 +247,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -259,7 +259,7 @@ namespace ucs2
// (2) perform transform to copy the narrow string to our
// wide string
std::transform(rhs.begin(), rhs.end(), mData.begin()+mLength, NarrowToWide);
// (3) ensure null termination
// (3) ensure nullptr termination
mLength += rhs.length();
mData[mLength] = 0;
return *this;
@@ -267,7 +267,7 @@ namespace ucs2
inline string & string::operator+=(const char_type * rhs)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -279,7 +279,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -388,7 +388,7 @@ namespace ucs2
inline string & string::assign(const char_type * rhs)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -401,7 +401,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -409,7 +409,7 @@ namespace ucs2
inline string & string::assign(const char_type * rhs, size_type count)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -422,7 +422,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -463,7 +463,7 @@ namespace ucs2
inline string & string::assign(const char_type * first, const char_type * last)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!first || !last)
{
mData[0] = 0;
@@ -476,14 +476,14 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *first++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
inline string & string::append(const char_type * rhs)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -495,14 +495,14 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
inline string & string::append(const char_type * rhs, size_type count)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -514,7 +514,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -558,7 +558,7 @@ namespace ucs2
inline string & string::append(const char_type * first, const char_type * last)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!first || !last)
{
return *this;
@@ -570,7 +570,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *first++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -12,7 +12,7 @@ namespace Base
{
for(unsigned i = 0; i < 31; i++)
{
m_blocks[i] = NULL;
m_blocks[i] = nullptr;
}
}
@@ -21,7 +21,7 @@ namespace Base
// free all allocated memory blocks
for(unsigned i = 0; i < 31; i++)
{
while(m_blocks[i] != NULL)
while(m_blocks[i] != nullptr)
{
unsigned *tmp = m_blocks[i];
m_blocks[i] = (unsigned *)*m_blocks[i];
@@ -36,7 +36,7 @@ namespace Base
void *BlockAllocator::getBlock(unsigned bytes)
{
unsigned accum = 16, bits = 16;
unsigned *handle = NULL;
unsigned *handle = nullptr;
// Perform a binary search looking for the highest bit.
@@ -96,7 +96,7 @@ namespace Base
void BlockAllocator::returnBlock(unsigned *handle)
{
// C++ allows for safe deletion of a NULL pointer
// C++ allows for safe deletion of a nullptr pointer
if(handle)
{
// Update the allocator linked list, insert this entry at the head
@@ -26,8 +26,8 @@ namespace Base
mCond(),
mThreadCount(0)
{
pthread_mutex_init(&mMutex, NULL);
pthread_cond_init(&mCond, NULL);
pthread_mutex_init(&mMutex, nullptr);
pthread_cond_init(&mCond, nullptr);
}
CEvent::~CEvent()
@@ -74,7 +74,7 @@ namespace Base
struct timeval now;
struct timespec abs_timeout;
gettimeofday(&now, NULL);
gettimeofday(&now, nullptr);
abs_timeout.tv_sec = now.tv_sec + timeout/1000;
abs_timeout.tv_nsec = now.tv_usec * 1000 + (timeout%1000)*1000000;
abs_timeout.tv_sec += abs_timeout.tv_nsec / 1000000000;
@@ -77,8 +77,8 @@ namespace Base
CThreadPool::CMember::CMember(CThreadPool * parent) :
mParent(parent),
mFunction(NULL),
mArgument(NULL),
mFunction(nullptr),
mArgument(nullptr),
mSemaphore()
{
StartThread();
@@ -117,8 +117,8 @@ namespace Base
if (mFunction)
{
mFunction(mArgument);
mArgument = NULL;
mFunction = NULL;
mArgument = nullptr;
mFunction = nullptr;
}
else if (mParent->OnDestory(this))
mThreadContinue = false;
@@ -173,7 +173,7 @@ namespace Base
}
////////////////////////////////////////
// (3) Delete the null member threads
// (3) Delete the nullptr member threads
mMutex.Lock();
while (!mNullMember.empty())
{
@@ -224,7 +224,7 @@ namespace Base
}
////////////////////////////////////////
// (2) Delete any null member threads.
// (2) Delete any nullptr member threads.
while (!mNullMember.empty())
{
delete mNullMember.front();
@@ -501,8 +501,8 @@ namespace soe
}
else
{
//find null terminator, if don't find it before maxLen, then err
const unsigned char *strEnd = NULL;
//find nullptr terminator, if don't find it before maxLen, then err
const unsigned char *strEnd = nullptr;
unsigned strLen = 0;
for (;strLen<maxLen && strLen < size;strLen++)
{
@@ -513,7 +513,7 @@ namespace soe
break;
}
}
if (strEnd == NULL)
if (strEnd == nullptr)
return 0;
data.assign((const char *)stream, (const char *)strEnd);
@@ -107,7 +107,7 @@ unsigned GenericAPICore::submitRequest(GenericRequest *req, GenericResponse *res
}
req->setTrack(m_currTrack);
res->setTrack(m_currTrack);
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -125,7 +125,7 @@ unsigned GenericAPICore::submitRequest(GenericRequest *req, GenericResponse *res
}
req->setTrack(m_currTrack);
res->setTrack(m_currTrack);
time_t timeout = time(NULL) + reqTimeout;
time_t timeout = time(nullptr) + reqTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -140,7 +140,7 @@ void GenericAPICore::process()
GenericResponse *res;
// Process timeout on pending requests - regardless of whether processing is suspended or not
while((m_outCount > 0) && ((req = m_outboundQueue.front().first)->getTimeout() <= time(NULL)))
while((m_outCount > 0) && ((req = m_outboundQueue.front().first)->getTimeout() <= time(nullptr)))
{
--m_outCount;
res = m_outboundQueue.front().second;
@@ -152,7 +152,7 @@ void GenericAPICore::process()
}
// Process timeout on pending responses
while((m_pendingCount > 0) && ((res = (*m_pending.begin()).second)->getTimeout() <= time(NULL)))
while((m_pendingCount > 0) && ((res = (*m_pending.begin()).second)->getTimeout() <= time(nullptr)))
{
--m_pendingCount;
m_pending.erase(m_pending.begin());
@@ -165,7 +165,7 @@ void GenericAPICore::process()
while(m_outCount > 0)
{
GenericConnection *con = getNextActiveConnection();
if (con != NULL)
if (con != nullptr)
{
pair<GenericRequest *, GenericResponse *> out_pair = m_outboundQueue.front();
@@ -184,7 +184,7 @@ void GenericAPICore::process()
else
{
#ifdef USE_SERIALIZE_LIB
const unsigned char *msgBuf = NULL;
const unsigned char *msgBuf = nullptr;
unsigned msgSize = 0;
msgBuf = req->pack(msgSize);
con->Send(msgBuf, msgSize);
@@ -222,7 +222,7 @@ GenericConnection *GenericAPICore::getNextActiveConnection()
unsigned startIndex = m_nextConnectionIndex;
unsigned maxIndex = m_serverConnections.size() - 1;
GenericConnection *con = NULL;
GenericConnection *con = nullptr;
//loop until we find an active connection, or until we get back
// to where we started
@@ -242,7 +242,7 @@ GenericConnection *GenericAPICore::getNextActiveConnection()
//went past end of vector, start back at 0
m_nextConnectionIndex = 0;
}
}while (con == NULL && m_nextConnectionIndex != startIndex);
}while (con == nullptr && m_nextConnectionIndex != startIndex);
return con;
}
@@ -28,7 +28,7 @@ unsigned GenericConnection::ms_crcBytes = 0;
GenericConnection::GenericConnection(const char *host, short port, GenericAPICore *apiCore, unsigned reconnectTimeout, unsigned noDataTimeoutSecs, unsigned noAckTimeoutSecs, unsigned incomingBufSizeInKB, unsigned outgoingBufSizeInKB, unsigned keepAlive, unsigned maxRecvMessageSizeInKB, unsigned holdTime)
: m_bConnected(false),
m_apiCore(apiCore),
m_con(NULL),
m_con(nullptr),
m_host(host),
m_nextHost(host),
m_port(port),
@@ -72,8 +72,8 @@ GenericConnection::~GenericConnection()
{
if(m_con)
{
m_con->SetHandler(NULL);
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to null, so it wont
m_con->SetHandler(nullptr);
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to nullptr, so it wont
m_con->Release();
}
@@ -96,7 +96,7 @@ void GenericConnection::disconnect()
{
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
m_con = nullptr;
}
m_conState = CON_DISCONNECT;
m_bConnected = false;
@@ -112,7 +112,7 @@ void GenericConnection::OnTerminated(UdpConnection *con)
if(m_con)
{
m_con->Release();
m_con = NULL;
m_con = nullptr;
}
m_conState = CON_DISCONNECT;
m_bConnected = false;
@@ -146,7 +146,7 @@ void GenericConnection::OnRoutePacket(UdpConnection *con, const unsigned char *d
get(iter, type);
get(iter, track);
#endif
GenericResponse *res = NULL;
GenericResponse *res = nullptr;
// the following if block is a temporary fix that prevents
// a crash with a game team in which they occasionally find
@@ -208,7 +208,7 @@ void GenericConnection::process(bool giveTime)
{
m_con->SetHandler(this);
m_conState = CON_NEGOTIATE;
m_conTimeout = time(NULL) + m_reconnectTimeout;
m_conTimeout = time(nullptr) + m_reconnectTimeout;
}
break;
case CON_NEGOTIATE:
@@ -225,12 +225,12 @@ void GenericConnection::process(bool giveTime)
m_apiCore->OnConnect(m_host.c_str(), m_port);
m_bConnected = true;
}
else if(time(NULL) > m_conTimeout)
else if(time(nullptr) > m_conTimeout)
{
// we did not connect
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
m_con = nullptr;
m_conState = CON_DISCONNECT;
m_bConnected = false;
}
@@ -246,7 +246,7 @@ void GenericConnection::process(bool giveTime)
{
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
m_con = nullptr;
}
}
@@ -96,7 +96,7 @@ void UdpConnection::Init(UdpManager *udpManager, UdpPlatformAddress destIp, int
mLastClockSyncTime = 0;
mDataHoldTime = 0;
mGettingTime = false;
mHandler = NULL;
mHandler = nullptr;
mOtherSideProtocolVersion = 0;
mNoDataTimeout = mUdpManager->mParams.noDataTimeout;
@@ -108,7 +108,7 @@ void UdpConnection::Init(UdpManager *udpManager, UdpPlatformAddress destIp, int
mIcmpErrorRetryStartStamp = 0; // when the timer started for ICMP error retry delay (gets reset on a successful packet receive)
mPortRemapRequestStartStamp = 0;
mEncryptXorBuffer = NULL;
mEncryptXorBuffer = nullptr;
mEncryptExpansionBytes = 0;
mOrderedCountOutgoing = 0;
mOrderedCountOutgoing2 = 0;
@@ -120,7 +120,7 @@ void UdpConnection::Init(UdpManager *udpManager, UdpPlatformAddress destIp, int
mConnectAttemptTimeout = 0;
mConnectionCreateTime = mUdpManager->CachedClock();
mSimulateOutgoingQueueBytes = 0;
mPassThroughData = NULL;
mPassThroughData = nullptr;
mSilentDisconnect = false;
mLastSendBin = 0;
@@ -140,7 +140,7 @@ UdpConnection::~UdpConnection()
{
UdpGuard myGuard(&mGuard);
assert(mUdpManager == NULL); // this should not be possible, since the UdpManager holds a reference to us until we are disconnected and disassociated from the manager. If you are hitting this, then odds are the application is releasing the UdpConnection object more times than it should
assert(mUdpManager == nullptr); // this should not be possible, since the UdpManager holds a reference to us until we are disconnected and disassociated from the manager. If you are hitting this, then odds are the application is releasing the UdpConnection object more times than it should
for (int i = 0; i < cReliableChannelCount; i++)
delete mChannel[i];
@@ -189,7 +189,7 @@ void UdpConnection::InternalDisconnect(int flushTimeout, DisconnectReason reason
if (mStatus == cStatusNegotiating)
flushTimeout = 0;
if (mUdpManager != NULL)
if (mUdpManager != nullptr)
{
if (flushTimeout > 0)
{
@@ -219,7 +219,7 @@ void UdpConnection::InternalDisconnect(int flushTimeout, DisconnectReason reason
}
UdpManager *holdUdpManager = mUdpManager;
mUdpManager = NULL;
mUdpManager = nullptr;
mStatus = cStatusDisconnected;
// only hold a reference to the UdpManager if it is not currently being destructed.
@@ -274,7 +274,7 @@ bool UdpConnection::Send(UdpChannel channel, const void *data, int dataLen)
if (dataLen == 0) // zero length packets are ignored
return(false);
assert(data != NULL); // can't send a null packet
assert(data != nullptr); // can't send a nullptr packet
// zero-escape application packets that start with 0
if ((*(const udp_uchar *)data) == 0)
@@ -290,7 +290,7 @@ bool UdpConnection::Send(UdpChannel channel, const LogicalPacket *packet)
{
UdpGuard myGuard(&mGuard);
assert(packet != NULL); // can't send a null packet
assert(packet != nullptr); // can't send a nullptr packet
if (mStatus != cStatusConnected) // if we are no longer connected
return(false);
@@ -337,7 +337,7 @@ bool UdpConnection::InternalSend(UdpChannel channel, const udp_uchar *data, int
{
udp_uchar *bufPtr = tempBuffer;
memcpy(bufPtr, data, dataLen);
if (data2 != NULL)
if (data2 != nullptr)
memcpy(bufPtr + dataLen, data2, dataLen2);
PhysicalSend(bufPtr, totalDataLen, true);
return(true);
@@ -350,9 +350,9 @@ bool UdpConnection::InternalSend(UdpChannel channel, const udp_uchar *data, int
bufPtr[1] = cUdpPacketOrdered;
UdpMisc::PutValue16(bufPtr + 2, (udp_ushort)(++mOrderedCountOutgoing & 0xffff));
memcpy(bufPtr + 4, data, dataLen);
if (data2 != NULL)
if (data2 != nullptr)
memcpy(bufPtr + 4 + dataLen, data2, dataLen2);
BufferedSend(bufPtr, totalDataLen + 4, NULL, 0, true);
BufferedSend(bufPtr, totalDataLen + 4, nullptr, 0, true);
return(true);
break;
}
@@ -363,7 +363,7 @@ bool UdpConnection::InternalSend(UdpChannel channel, const udp_uchar *data, int
bufPtr[1] = cUdpPacketOrdered2;
UdpMisc::PutValue16(bufPtr + 2, (udp_ushort)(++mOrderedCountOutgoing2 & 0xffff));
memcpy(bufPtr + 4, data, dataLen);
if (data2 != NULL)
if (data2 != nullptr)
memcpy(bufPtr + 4 + dataLen, data2, dataLen2);
PhysicalSend(bufPtr, totalDataLen + 4, true);
return(true);
@@ -375,7 +375,7 @@ bool UdpConnection::InternalSend(UdpChannel channel, const udp_uchar *data, int
case cUdpChannelReliable4:
{
int num = channel - cUdpChannelReliable1;
if (mChannel[num] == NULL)
if (mChannel[num] == nullptr)
mChannel[num] = new UdpReliableChannel(num, this, &mUdpManager->mParams.reliable[num]);
mChannel[num]->Send(data, dataLen, data2, dataLen2);
return(true);
@@ -410,9 +410,9 @@ void UdpConnection::GetStats(UdpConnectionStatistics *cs)
{
UdpGuard myGuard(&mGuard);
assert(cs != NULL);
assert(cs != nullptr);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
*cs = mConnectionStats;
@@ -428,7 +428,7 @@ void UdpConnection::GetStats(UdpConnectionStatistics *cs)
if (cs->syncTheirSent > 0)
cs->percentReceivedSuccess = (float)cs->syncOurReceived / (float)cs->syncTheirSent;
cs->reliableAveragePing = 0;
if (mChannel[0] != NULL)
if (mChannel[0] != nullptr)
cs->reliableAveragePing = mChannel[0]->GetAveragePing();
}
@@ -437,7 +437,7 @@ void UdpConnection::ProcessRawPacket(const UdpManager::PacketHistoryEntry *e)
UdpRef ref(this);
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
if (e->mLen == 0)
@@ -572,7 +572,7 @@ void UdpConnection::ProcessRawPacket(const UdpManager::PacketHistoryEntry *e)
*decryptPtr++ = finalStart[1];
int len = (this->*(mDecryptFunction[j]))(decryptPtr, finalStart + 2, finalLen - 2);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
if (len == -1)
@@ -627,7 +627,7 @@ void UdpConnection::ProcessCookedPacket(const udp_uchar *data, int dataLen)
{
udp_uchar buf[256];
udp_uchar *bufPtr;
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
if (data[0] == 0 && dataLen > 1)
@@ -826,7 +826,7 @@ void UdpConnection::ProcessCookedPacket(const udp_uchar *data, int dataLen)
// (while processing this packet) ended up touching the packet-data and corrupting the next
// packet in the multi-sequence.
CallbackCorruptPacket(data, dataLen, cUdpCorruptionReasonMultiPacket);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
}
else
@@ -943,7 +943,7 @@ void UdpConnection::ProcessCookedPacket(const udp_uchar *data, int dataLen)
case cUdpPacketFragment4:
{
int num = (data[1] - cUdpPacketReliable1) % cReliableChannelCount;
if (mChannel[num] == NULL)
if (mChannel[num] == nullptr)
mChannel[num] = new UdpReliableChannel(num, this, &mUdpManager->mParams.reliable[num]);
mChannel[num]->ReliablePacket(data, dataLen);
break;
@@ -954,7 +954,7 @@ void UdpConnection::ProcessCookedPacket(const udp_uchar *data, int dataLen)
case cUdpPacketAck4:
{
int num = data[1] - cUdpPacketAck1;
if (mChannel[num] != NULL)
if (mChannel[num] != nullptr)
mChannel[num]->AckPacket(data, dataLen);
break;
}
@@ -964,7 +964,7 @@ void UdpConnection::ProcessCookedPacket(const udp_uchar *data, int dataLen)
case cUdpPacketAckAll4:
{
int num = data[1] - cUdpPacketAckAll1;
if (mChannel[num] != NULL)
if (mChannel[num] != nullptr)
mChannel[num]->AckAllPacket(data, dataLen);
break;
}
@@ -1015,7 +1015,7 @@ void UdpConnection::FlagPortUnreachable()
void UdpConnection::GiveTime(bool fromManager)
{
UdpGuard myGuard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
if (fromManager && GetRefCount() == 2)
@@ -1115,11 +1115,11 @@ void UdpConnection::InternalGiveTime()
int totalPendingBytes = 0;
for (int i = 0; i < cReliableChannelCount; i++)
{
if (mChannel[i] != NULL)
if (mChannel[i] != nullptr)
{
totalPendingBytes += mChannel[i]->TotalPendingBytes();
int myNext = mChannel[i]->GiveTime();
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return; // giving the reliable channel time caused it to callback the application which may disconnect us
nextSchedule = udpMin(nextSchedule, myNext);
}
@@ -1208,7 +1208,7 @@ void UdpConnection::InternalGiveTime()
break;
}
if (mUdpManager != NULL)
if (mUdpManager != nullptr)
{
// safety to prevent us for scheduling ourselves for a time period that has already passed,
// as doing so could result in infinite looping in the priority queue processing.
@@ -1227,7 +1227,7 @@ int UdpConnection::TotalPendingBytes() const
int total = 0;
for (int i = 0; i < cReliableChannelCount; i++)
{
if (mChannel[i] != NULL)
if (mChannel[i] != nullptr)
total += mChannel[i]->TotalPendingBytes();
}
return(total);
@@ -1293,7 +1293,7 @@ void UdpConnection::ExpireReceiveBin()
void UdpConnection::PhysicalSend(const udp_uchar *data, int dataLen, bool appendAllowed)
{
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
// if we attempt to do a physical send (ie. encrypt/compress/crc a packet) while we are not connected
@@ -1322,7 +1322,7 @@ void UdpConnection::PhysicalSend(const udp_uchar *data, int dataLen, bool append
// we know this internal packet will not be a connect or confirm packet since they are sent directly to RawSend to avoid getting encrypted
*destPtr++ = finalStart[1];
int len = (this->*(mEncryptFunction[j]))(destPtr, finalStart + 2, finalLen - 2);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
// if this assert triggers, it means the encryption pass expanded the size of the encrypted
@@ -1393,8 +1393,8 @@ void UdpConnection::PhysicalSend(const udp_uchar *data, int dataLen, bool append
// can note where the ack was placed and replace it
udp_uchar *UdpConnection::BufferedSend(const udp_uchar *data, int dataLen, const udp_uchar *data2, int dataLen2, bool appendAllowed)
{
if (mUdpManager == NULL)
return(NULL);
if (mUdpManager == nullptr)
return(nullptr);
int used = (int)(mMultiBufferPtr - mMultiBufferData);
int actualMaxDataHoldSize = udpMin(mUdpManager->mParams.maxDataHoldSize, mConnectionConfig.maxRawPacketSize);
@@ -1409,7 +1409,7 @@ udp_uchar *UdpConnection::BufferedSend(const udp_uchar *data, int dataLen, const
FlushMultiBuffer();
// now send it (the multi-buffer is empty if you need to use it temporarily to concatenate two data chunks -- it is large enough to hold the largest raw packet)
if (data2 != NULL)
if (data2 != nullptr)
{
memcpy(mMultiBufferData, data, dataLen);
memcpy(mMultiBufferData + dataLen, data2, dataLen2);
@@ -1417,7 +1417,7 @@ udp_uchar *UdpConnection::BufferedSend(const udp_uchar *data, int dataLen, const
}
else
PhysicalSend(data, dataLen, appendAllowed);
return(NULL);
return(nullptr);
}
// if this data will not fit into buffer
@@ -1445,7 +1445,7 @@ udp_uchar *UdpConnection::BufferedSend(const udp_uchar *data, int dataLen, const
udp_uchar *placementPtr = mMultiBufferPtr;
memcpy(mMultiBufferPtr, data, dataLen);
mMultiBufferPtr += dataLen;
if (data2 != NULL)
if (data2 != nullptr)
{
memcpy(mMultiBufferPtr, data2, dataLen2);
mMultiBufferPtr += dataLen2;
@@ -1454,7 +1454,7 @@ udp_uchar *UdpConnection::BufferedSend(const udp_uchar *data, int dataLen, const
if ((mMultiBufferPtr - mMultiBufferData) >= actualMaxDataHoldSize)
{
FlushMultiBuffer();
placementPtr = NULL; // it got flushed
placementPtr = nullptr; // it got flushed
}
return(placementPtr);
}
@@ -1474,7 +1474,7 @@ void UdpConnection::FlushMultiBuffer()
// notify all the reliable channels to clear their buffered acks
for (int i = 0; i < cReliableChannelCount; i++)
{
if (mChannel[i] != NULL)
if (mChannel[i] != nullptr)
{
mChannel[i]->ClearBufferedAck();
}
@@ -1684,7 +1684,7 @@ void UdpConnection::SetupEncryptModel()
mEncryptExpansionBytes += 0;
// set up encrypt buffer (random numbers generated based on seed)
if (mEncryptXorBuffer == NULL)
if (mEncryptXorBuffer == nullptr)
{
int len = ((mUdpManager->mParams.maxRawPacketSize + 1) / 4) * 4;
mEncryptXorBuffer = new udp_uchar[len];
@@ -1718,7 +1718,7 @@ void UdpConnection::GetChannelStatus(UdpChannel channel, ChannelStatus *channelS
case cUdpChannelReliable2:
case cUdpChannelReliable3:
case cUdpChannelReliable4:
if (mChannel[channel - cUdpChannelReliable1] != NULL)
if (mChannel[channel - cUdpChannelReliable1] != nullptr)
{
mChannel[channel - cUdpChannelReliable1]->GetChannelStatus(channelStatus);
}
@@ -1763,7 +1763,7 @@ char *UdpConnection::GetDestinationString(char *buf, int bufLen) const
UdpGuard myGuard(&mGuard);
if (bufLen < 22)
return(NULL);
return(nullptr);
UdpPlatformAddress ip = GetDestinationIp();
int port = GetDestinationPort();
char hold[256];
@@ -1794,7 +1794,7 @@ void UdpConnection::OnRoutePacket(const udp_uchar *data, int dataLen)
{
UdpGuard myGuard(&mHandlerGuard);
if (mHandler != NULL)
if (mHandler != nullptr)
{
mHandler->OnRoutePacket(this, data, dataLen);
}
@@ -1814,7 +1814,7 @@ void UdpConnection::OnRoutePacket(const udp_uchar *data, int dataLen)
void UdpConnection::OnConnectComplete()
{
UdpGuard myGuard(&mHandlerGuard);
if (mHandler != NULL)
if (mHandler != nullptr)
{
mHandler->OnConnectComplete(this);
}
@@ -1823,7 +1823,7 @@ void UdpConnection::OnConnectComplete()
void UdpConnection::OnTerminated()
{
UdpGuard myGuard(&mHandlerGuard);
if (mHandler != NULL)
if (mHandler != nullptr)
{
mHandler->OnTerminated(this);
}
@@ -1832,7 +1832,7 @@ void UdpConnection::OnTerminated()
void UdpConnection::OnCrcReject(const udp_uchar *data, int dataLen)
{
UdpGuard myGuard(&mHandlerGuard);
if (mHandler != NULL)
if (mHandler != nullptr)
{
mHandler->OnCrcReject(this, data, dataLen);
}
@@ -1841,7 +1841,7 @@ void UdpConnection::OnCrcReject(const udp_uchar *data, int dataLen)
void UdpConnection::OnPacketCorrupt(const udp_uchar *data, int dataLen, UdpCorruptionReason reason)
{
UdpGuard myGuard(&mHandlerGuard);
if (mHandler != NULL)
if (mHandler != nullptr)
{
mHandler->OnPacketCorrupt(this, data, dataLen, reason);
}
@@ -153,7 +153,7 @@ class UdpConnection : public UdpGuardedRefCount, public PriorityQueueMember, pub
int ConnectionAge() const;
// returns the UdpManager object that is managing this connection
// will return NULL if the connection has been disconnected for some reason (because disconnecting severes the link to UdpManager)
// will return nullptr if the connection has been disconnected for some reason (because disconnecting severes the link to UdpManager)
UdpManager *GetUdpManager() const;
// returns the 32-bit encryption-code that was negotiated as part of the connection-establishment process.
@@ -234,9 +234,9 @@ class UdpConnection : public UdpGuardedRefCount, public PriorityQueueMember, pub
friend class UdpManager;
friend class UdpReliableChannel;
// note: if connectPacket is NULL, that means this connection object is being created to establish
// note: if connectPacket is nullptr, that means this connection object is being created to establish
// a new connection to the specified ip/port (ie. the connection starts out in cStatusNegotiating mode)
// if connectPacket is non-NULL, that menas this connection object is being created to handle an
// if connectPacket is non-nullptr, that menas this connection object is being created to handle an
// incoming connect request and it will start out in cStatusConnected mode.
UdpConnection(UdpManager *udpManager, UdpPlatformAddress destIp, int destPort, int timeout); // starts connection-establishment protocol
UdpConnection(UdpManager *udpManager, const UdpManager::PacketHistoryEntry *e); // starts already connected, replying to connection request
@@ -281,7 +281,7 @@ class UdpConnection : public UdpGuardedRefCount, public PriorityQueueMember, pub
void RawSend(const udp_uchar *data, int dataLen); // nothing happens to the data here, it is given to the udpmanager and sent out the port
void PhysicalSend(const udp_uchar *data, int dataLen, bool appendAllowed); // sends a physical packet (encrypts and adds crc bytes)
udp_uchar *BufferedSend(const udp_uchar *data, int dataLen, const udp_uchar *data2, int dataLen2, bool appendAllowed); // buffers logical packets waiting til we have more data (makes multi-packets)
bool InternalSend(UdpChannel channel, const udp_uchar *data, int dataLen, const udp_uchar *data2 = NULL, int dataLen2 = 0);
bool InternalSend(UdpChannel channel, const udp_uchar *data, int dataLen, const udp_uchar *data2 = nullptr, int dataLen2 = 0);
void InternalGiveTime();
void InternalDisconnect(int flushTimeout, DisconnectReason reason);
@@ -527,7 +527,7 @@ inline void UdpConnection::ScheduleTimeNow()
// prevents us from reprioritizing to 0, only to shortly thereafter be reprioritized to where we actually belong.
if (!mGettingTime)
{
if (mUdpManager != NULL)
if (mUdpManager != nullptr)
mUdpManager->SetPriority(this, 0);
}
}
@@ -575,7 +575,7 @@ inline int UdpConnection::LastReceive(UdpClockStamp useStamp) const
inline int UdpConnection::LastReceive() const
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
return(mUdpManager->CachedClockElapsed(mLastReceiveTime));
}
@@ -583,7 +583,7 @@ inline int UdpConnection::LastReceive() const
inline int UdpConnection::ConnectionAge() const
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
return(mUdpManager->CachedClockElapsed(mConnectionCreateTime));
}
@@ -591,7 +591,7 @@ inline int UdpConnection::ConnectionAge() const
inline int UdpConnection::LastSend() const
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
return(mUdpManager->CachedClockElapsed(mLastSendTime));
}
@@ -599,7 +599,7 @@ inline int UdpConnection::LastSend() const
inline udp_ushort UdpConnection::ServerSyncStampShort() const
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
return((udp_ushort)(mUdpManager->LocalSyncStampShort() + (mSyncTimeDelta & 0xffff)));
}
@@ -607,7 +607,7 @@ inline udp_ushort UdpConnection::ServerSyncStampShort() const
inline udp_uint UdpConnection::ServerSyncStampLong() const
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
return(mUdpManager->LocalSyncStampLong() + mSyncTimeDelta);
}
@@ -649,7 +649,7 @@ inline UdpConnection::DisconnectReason UdpConnection::GetOtherSideDisconnectReas
inline int UdpConnection::OutgoingBytesLastSecond()
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
ExpireSendBin();
@@ -659,7 +659,7 @@ inline int UdpConnection::OutgoingBytesLastSecond()
inline int UdpConnection::IncomingBytesLastSecond()
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
ExpireReceiveBin();
@@ -101,7 +101,7 @@ bool UdpPlatformDriver::SocketOpen(int port, int incomingBufferSize, int outgoin
addr_loc.sin_family = PF_INET;
addr_loc.sin_port = htons((unsigned short)port);
addr_loc.sin_addr.s_addr = htonl(INADDR_ANY);
if (bindIpAddress != NULL && bindIpAddress[0] != 0)
if (bindIpAddress != nullptr && bindIpAddress[0] != 0)
{
unsigned long address = inet_addr(bindIpAddress);
if (address != INADDR_NONE)
@@ -201,7 +201,7 @@ bool UdpPlatformDriver::GetHostByName(UdpPlatformAddress *ipAddress, const char
{
struct hostent *lphp;
lphp = gethostbyname(hostName);
if (lphp == NULL)
if (lphp == nullptr)
{
address = 0;
}
@@ -223,7 +223,7 @@ bool UdpPlatformDriver::GetSelfAddress(UdpPlatformAddress *ipAddress, bool prefe
if (gethostname(hostname, sizeof(hostname)) == 0)
{
struct hostent *entry = gethostbyname(hostname);
if (entry != NULL)
if (entry != nullptr)
{
for (int i = 0; entry->h_addr_list[i] != 0; i++)
{
@@ -273,7 +273,7 @@ UdpClockStamp UdpPlatformDriver::Clock()
UdpGuard guard(&mData->clockGuard);
struct timeval tv;
gettimeofday(&tv, NULL);
gettimeofday(&tv, nullptr);
UdpClockStamp cs = static_cast<UdpClockStamp>(tv.tv_sec) * 1000 + static_cast<UdpClockStamp>(tv.tv_usec / 1000);
cs += mData->currentCorrection;
if (cs < mData->lastStamp)
@@ -319,7 +319,7 @@ int IcmpReceive(SOCKET socket, unsigned *address, int *port)
return(-1);
struct cmsghdr *cmsg;
for(cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg))
for(cmsg = CMSG_FIRSTHDR(&msgh); cmsg != nullptr; cmsg = CMSG_NXTHDR(&msgh, cmsg))
{
if(cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
{
@@ -378,7 +378,7 @@ void *GoThread(void *param)
thread->mThreadData->running = false;
thread->mThreadData->handle = 0;
thread->Release();
return(NULL);
return(nullptr);
}
UdpPlatformThreadObject::~UdpPlatformThreadObject()
@@ -435,7 +435,7 @@ char *UdpPlatformAddress::GetAddress(char *buffer, int bufferLen) const
*buffer = 0;
return(buffer);
}
assert(buffer != NULL);
assert(buffer != nullptr);
sprintf(buffer, "%d.%d.%d.%d", mData[0], mData[1], mData[2], mData[3]);
return(buffer);
}
@@ -444,7 +444,7 @@ void UdpPlatformAddress::SetAddress(const char *address)
{
for (int i = 0; i < 4; i++)
{
mData[i] = (unsigned char)strtol(address, NULL, 10);
mData[i] = (unsigned char)strtol(address, nullptr, 10);
while (*address >= '0' && *address <= '9')
address++;
if (*address != 0)
@@ -102,7 +102,7 @@ bool UdpPlatformDriver::SocketOpen(int port, int incomingBufferSize, int outgoin
addr_loc.sin_family = PF_INET;
addr_loc.sin_port = htons((unsigned short)port);
addr_loc.sin_addr.s_addr = htonl(INADDR_ANY);
if (bindIpAddress != NULL && bindIpAddress[0] != 0)
if (bindIpAddress != nullptr && bindIpAddress[0] != 0)
{
unsigned long address = inet_addr(bindIpAddress);
if (address != INADDR_NONE)
@@ -205,7 +205,7 @@ bool UdpPlatformDriver::GetHostByName(UdpPlatformAddress *ipAddress, const char
{
struct hostent *lphp;
lphp = gethostbyname(hostName);
if (lphp == NULL)
if (lphp == nullptr)
{
address = 0;
}
@@ -227,7 +227,7 @@ bool UdpPlatformDriver::GetSelfAddress(UdpPlatformAddress *ipAddress, bool prefe
if (gethostname(hostname, sizeof(hostname)) == 0)
{
struct hostent *entry = gethostbyname(hostname);
if (entry != NULL)
if (entry != nullptr)
{
for (int i = 0; entry->h_addr_list[i] != 0; i++)
{
@@ -329,10 +329,10 @@ unsigned __stdcall GoThread(void *param)
UdpPlatformThreadObject::~UdpPlatformThreadObject()
{
#ifndef UDPLIBRARY_SINGLE_THREAD
if (mThreadData->handle != NULL)
if (mThreadData->handle != nullptr)
{
CloseHandle(mThreadData->handle);
mThreadData->handle = NULL;
mThreadData->handle = nullptr;
}
#endif
delete mThreadData;
@@ -343,7 +343,7 @@ void UdpPlatformThreadObject::Start()
AddRef();
#ifndef UDPLIBRARY_SINGLE_THREAD
unsigned threadId;
mThreadData->handle = (HANDLE)_beginthreadex(NULL, 0, &GoThread, this, 0, &threadId);
mThreadData->handle = (HANDLE)_beginthreadex(nullptr, 0, &GoThread, this, 0, &threadId);
#else
GoThread(this); // run it inline in main thread (blocks til it's finished, so odds are it won't work, but they shouldn't be using it anyhow in this mode)
#endif
@@ -352,7 +352,7 @@ void UdpPlatformThreadObject::Start()
UdpPlatformThreadObject::UdpPlatformThreadObject()
{
mThreadData = new UdpPlatformThreadData;
mThreadData->handle = NULL;
mThreadData->handle = nullptr;
mThreadData->running = false;
}
@@ -389,7 +389,7 @@ char *UdpPlatformAddress::GetAddress(char *buffer, int bufferLen) const
*buffer = 0;
return(buffer);
}
assert(buffer != NULL);
assert(buffer != nullptr);
sprintf(buffer, "%d.%d.%d.%d", mData[0], mData[1], mData[2], mData[3]);
return(buffer);
}
@@ -38,11 +38,11 @@ template<typename T> class HashTable
bool Remove(T& obj, int hashValue);
void Reset(); // removes all entries from the table
T *FindFirst(int hashValue) const; // returns NULL if not found
T *FindNext(T *prevResult) const; // returns NULL if not found
T *FindFirst(int hashValue) const; // returns nullptr if not found
T *FindNext(T *prevResult) const; // returns nullptr if not found
T *WalkFirst() const; // returns NULL if not found
T *WalkNext(T *prevResult) const; // returns NULL if not found
T *WalkFirst() const; // returns nullptr if not found
T *WalkNext(T *prevResult) const; // returns nullptr if not found
void Resize(int hashSize); // the actual hash size will be rounded up to the next larger prime number (very slow, not recommended)
void GetStatistics(HashTableStatistics *stats) const;
@@ -64,7 +64,7 @@ template<typename T> class HashTable
template<typename T> HashTable<T>::HashTable(int hashSize)
{
mTable = NULL;
mTable = nullptr;
mTableSize = 0;
mEntryCount = 0;
mStatUsedSlots = 0;
@@ -84,9 +84,9 @@ template<typename T> void HashTable<T>::Insert(T& obj, int hashValue)
entry->hashValue = hashValue;
int spot = ((unsigned)hashValue) % mTableSize;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
{
entry->nextEntry = NULL;
entry->nextEntry = nullptr;
mTable[spot] = entry;
mStatUsedSlots++;
}
@@ -103,14 +103,14 @@ template<typename T> bool HashTable<T>::Remove(T& obj, int hashValue)
int spot = ((unsigned)hashValue) % mTableSize;
HashEntry* next = mTable[spot];
HashEntry** prev = &mTable[spot];
while (next != NULL)
while (next != nullptr)
{
if (next->obj == obj && next->hashValue == hashValue)
{
*prev = next->nextEntry;
delete next;
mEntryCount--;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
mStatUsedSlots--;
return(true);
break;
@@ -127,17 +127,17 @@ template<typename T> void HashTable<T>::Reset()
for (int spot = 0; spot < mTableSize; spot++)
{
HashEntry *curr = mTable[spot];
if (curr != NULL)
if (curr != nullptr)
{
mStatUsedSlots--;
while (curr != NULL)
while (curr != nullptr)
{
HashEntry *next = curr->nextEntry;
delete curr;
mEntryCount--;
curr = next;
}
mTable[spot] = NULL;
mTable[spot] = nullptr;
}
}
}
@@ -145,13 +145,13 @@ template<typename T> void HashTable<T>::Reset()
template<typename T> T *HashTable<T>::FindFirst(int hashValue) const
{
HashEntry *entry = mTable[((unsigned)hashValue) % mTableSize];
while (entry != NULL)
while (entry != nullptr)
{
if (entry->hashValue == hashValue)
return(&entry->obj);
entry = entry->nextEntry;
}
return(NULL);
return(nullptr);
}
template<typename T> T *HashTable<T>::FindNext(T *prevResult) const
@@ -159,13 +159,13 @@ template<typename T> T *HashTable<T>::FindNext(T *prevResult) const
HashEntry *entry = (HashEntry *)(((char *)prevResult) - offsetof(HashEntry, obj));
int hashValue = entry->hashValue;
entry = entry->nextEntry;
while (entry != NULL)
while (entry != nullptr)
{
if (entry->hashValue == hashValue)
return(&entry->obj);
entry = entry->nextEntry;
}
return(NULL);
return(nullptr);
}
template<typename T> T *HashTable<T>::WalkFirst() const
@@ -173,10 +173,10 @@ template<typename T> T *HashTable<T>::WalkFirst() const
for (int bucket = 0; bucket < mTableSize; bucket++)
{
HashEntry *entry = mTable[bucket];
if (entry != NULL)
if (entry != nullptr)
return(&entry->obj);
}
return(NULL);
return(nullptr);
}
template<typename T> T *HashTable<T>::WalkNext(T *prevResult) const
@@ -185,17 +185,17 @@ template<typename T> T *HashTable<T>::WalkNext(T *prevResult) const
int bucket = ((unsigned)entry->hashValue) % mTableSize;
entry = entry->nextEntry;
if (entry != NULL)
if (entry != nullptr)
return(&entry->obj);
bucket++; // go onto next bucket
for (; bucket < mTableSize; bucket++)
{
HashEntry *entry = mTable[bucket];
if (entry != NULL)
if (entry != nullptr)
return(&entry->obj);
}
return(NULL);
return(nullptr);
}
template<typename T> void HashTable<T>::Resize(int hashSize)
@@ -215,16 +215,16 @@ template<typename T> void HashTable<T>::Resize(int hashSize)
for (int i = 0; i < oldSize; i++)
{
HashEntry* next = oldTable[i];
while (next != NULL)
while (next != nullptr)
{
HashEntry* hold = next;
next = next->nextEntry;
// insert hold into new table
int spot = ((unsigned)hold->hashValue) % mTableSize;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
{
hold->nextEntry = NULL;
hold->nextEntry = nullptr;
mTable[spot] = hold;
mStatUsedSlots++;
}
@@ -284,11 +284,11 @@ template<typename T, typename C = T> class ObjectHashTable
bool Remove(T *obj);
void Reset(); // removes all entries from the table
T *FindFirst(int hashValue) const; // returns NULL if not found
T *FindNext(T *prevResult) const; // returns NULL if not found
T *FindFirst(int hashValue) const; // returns nullptr if not found
T *FindNext(T *prevResult) const; // returns nullptr if not found
T *WalkFirst() const; // returns NULL if not found
T *WalkNext(T *prevResult) const; // returns NULL if not found
T *WalkFirst() const; // returns nullptr if not found
T *WalkNext(T *prevResult) const; // returns nullptr if not found
void Resize(int hashSize); // the actual hash size will be rounded up to the next larger prime number (very slow, not recommended)
void GetStatistics(HashTableStatistics *stats) const;
@@ -303,7 +303,7 @@ template<typename T, typename C = T> class ObjectHashTable
template<typename T, typename C> ObjectHashTable<T, C>::ObjectHashTable(int hashSize)
{
mTable = NULL;
mTable = nullptr;
mTableSize = 0;
mEntryCount = 0;
mStatUsedSlots = 0;
@@ -320,9 +320,9 @@ template<typename T, typename C> void ObjectHashTable<T, C>::Insert(T *obj, int
static_cast<C *>(obj)->mHashValue = hashValue;
int spot = ((unsigned)hashValue) % mTableSize;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
{
static_cast<C *>(obj)->mHashNextEntry = NULL;
static_cast<C *>(obj)->mHashNextEntry = nullptr;
mTable[spot] = obj;
mStatUsedSlots++;
}
@@ -339,14 +339,14 @@ template<typename T, typename C> bool ObjectHashTable<T, C>::Remove(T *obj)
int spot = ((unsigned)static_cast<C *>(obj)->mHashValue) % mTableSize;
T *cur = mTable[spot];
T **prev = &mTable[spot];
while (cur != NULL)
while (cur != nullptr)
{
if (cur == obj)
{
*prev = static_cast<C *>(cur)->mHashNextEntry;
static_cast<C *>(cur)->mHashNextEntry = NULL;
static_cast<C *>(cur)->mHashNextEntry = nullptr;
mEntryCount--;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
mStatUsedSlots--;
return(true);
break;
@@ -368,13 +368,13 @@ template<typename T, typename C> void ObjectHashTable<T, C>::Reset()
template<typename T, typename C> T *ObjectHashTable<T, C>::FindFirst(int hashValue) const
{
T *entry = mTable[((unsigned)hashValue) % mTableSize];
while (entry != NULL)
while (entry != nullptr)
{
if (static_cast<C *>(entry)->mHashValue == hashValue)
return(entry);
entry = static_cast<C *>(entry)->mHashNextEntry;
}
return(NULL);
return(nullptr);
}
template<typename T, typename C> T *ObjectHashTable<T, C>::FindNext(T *prevResult) const
@@ -382,13 +382,13 @@ template<typename T, typename C> T *ObjectHashTable<T, C>::FindNext(T *prevResul
T *entry = prevResult;
int hashValue = static_cast<C *>(entry)->mHashValue;
entry = static_cast<C *>(entry)->mHashNextEntry;
while (entry != NULL)
while (entry != nullptr)
{
if (static_cast<C *>(entry)->mHashValue == hashValue)
return(entry);
entry = static_cast<C *>(entry)->mHashNextEntry;
}
return(NULL);
return(nullptr);
}
template<typename T, typename C> T *ObjectHashTable<T, C>::WalkFirst() const
@@ -396,10 +396,10 @@ template<typename T, typename C> T *ObjectHashTable<T, C>::WalkFirst() const
for (int bucket = 0; bucket < mTableSize; bucket++)
{
T *entry = mTable[bucket];
if (entry != NULL)
if (entry != nullptr)
return(entry);
}
return(NULL);
return(nullptr);
}
template<typename T, typename C> T *ObjectHashTable<T, C>::WalkNext(T *prevResult) const
@@ -408,17 +408,17 @@ template<typename T, typename C> T *ObjectHashTable<T, C>::WalkNext(T *prevResul
int bucket = ((unsigned)static_cast<C *>(entry)->mHashValue) % mTableSize;
entry = static_cast<C *>(entry)->mHashNextEntry;
if (entry != NULL)
if (entry != nullptr)
return(entry);
bucket++; // go onto next bucket
for (; bucket < mTableSize; bucket++)
{
entry = mTable[bucket];
if (entry != NULL)
if (entry != nullptr)
return(entry);
}
return(NULL);
return(nullptr);
}
template<typename T, typename C> void ObjectHashTable<T, C>::Resize(int hashSize)
@@ -438,16 +438,16 @@ template<typename T, typename C> void ObjectHashTable<T, C>::Resize(int hashSize
for (int i = 0; i < oldSize; i++)
{
T *cur = oldTable[i];
while (cur != NULL)
while (cur != nullptr)
{
T *hold = cur;
cur = static_cast<C *>(cur)->mHashNextEntry;
// insert hold into new table
int spot = ((unsigned)static_cast<C *>(hold)->mHashValue) % mTableSize;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
{
static_cast<C *>(hold)->mHashNextEntry = NULL;
static_cast<C *>(hold)->mHashNextEntry = nullptr;
mTable[spot] = hold;
mStatUsedSlots++;
}
@@ -14,8 +14,8 @@ template<typename T> class UdpLinkedList;
template<typename M> class UdpLinkedListMember
{
public:
UdpLinkedListMember() { mPrev = NULL; mNext = NULL; }
UdpLinkedListMember(const UdpLinkedListMember &) { mPrev = NULL; mNext = NULL; }
UdpLinkedListMember() { mPrev = nullptr; mNext = nullptr; }
UdpLinkedListMember(const UdpLinkedListMember &) { mPrev = nullptr; mNext = nullptr; }
~UdpLinkedListMember() {}
#if defined(_MSC_VER) && (_MSC_VER < 1300) // MSVC 7.0 is the first version to support friend templates
@@ -60,8 +60,8 @@ template<typename T> class UdpLinkedList
template<typename T> UdpLinkedList<T>::UdpLinkedList(UdpLinkedListMember<T> T::*node)
{
mHead = NULL;
mTail = NULL;
mHead = nullptr;
mTail = nullptr;
mNode = node;
mCount = 0;
}
@@ -98,7 +98,7 @@ template<typename T> int UdpLinkedList<T>::Count() const
template<typename T> T *UdpLinkedList<T>::Position(int index) const
{
T *cur = mHead;
while (cur != NULL && index > 0)
while (cur != nullptr && index > 0)
{
cur = Next(cur);
index--;
@@ -109,43 +109,43 @@ template<typename T> T *UdpLinkedList<T>::Position(int index) const
template<typename T> T *UdpLinkedList<T>::Remove(T *cur)
{
UdpLinkedListMember<T> *node = &(cur->*mNode);
if (node->mPrev == NULL)
if (node->mPrev == nullptr)
mHead = node->mNext;
else
((node->mPrev)->*mNode).mNext = node->mNext;
if (node->mNext == NULL)
if (node->mNext == nullptr)
mTail = node->mPrev;
else
((node->mNext)->*mNode).mPrev = node->mPrev;
node->mNext = NULL;
node->mPrev = NULL;
node->mNext = nullptr;
node->mPrev = nullptr;
mCount--;
return(cur);
}
template<typename T> T *UdpLinkedList<T>::RemoveHead()
{
if (mHead == NULL)
return(NULL);
if (mHead == nullptr)
return(nullptr);
return(Remove(mHead));
}
template<typename T> T *UdpLinkedList<T>::RemoveTail()
{
if (mTail == NULL)
return(NULL);
if (mTail == nullptr)
return(nullptr);
return(Remove(mTail));
}
template<typename T> T *UdpLinkedList<T>::InsertHead(T *cur)
{
assert((cur->*mNode).mPrev == NULL);
assert((cur->*mNode).mNext == NULL);
assert((cur->*mNode).mPrev == nullptr);
assert((cur->*mNode).mNext == nullptr);
(cur->*mNode).mNext = mHead;
if (mHead != NULL)
if (mHead != nullptr)
{
(mHead->*mNode).mPrev = cur;
mHead = cur;
@@ -161,12 +161,12 @@ template<typename T> T *UdpLinkedList<T>::InsertHead(T *cur)
template<typename T> T *UdpLinkedList<T>::InsertTail(T *cur)
{
assert((cur->*mNode).mPrev == NULL);
assert((cur->*mNode).mNext == NULL);
assert((cur->*mNode).mPrev == nullptr);
assert((cur->*mNode).mNext == nullptr);
(cur->*mNode).mPrev = mTail;
if (mTail != NULL)
if (mTail != nullptr)
{
(mTail->*mNode).mNext = cur;
mTail = cur;
@@ -182,17 +182,17 @@ template<typename T> T *UdpLinkedList<T>::InsertTail(T *cur)
template<typename T> T *UdpLinkedList<T>::InsertAfter(T *cur, T *prev)
{
assert((cur->*mNode).mPrev == NULL);
assert((cur->*mNode).mNext == NULL);
assert((cur->*mNode).mPrev == nullptr);
assert((cur->*mNode).mNext == nullptr);
if (prev == NULL)
if (prev == nullptr)
return(InsertHead(cur));
(cur->*mNode).mPrev = prev;
(cur->*mNode).mNext = (prev->*mNode).mNext;
(prev->*mNode).mNext = cur;
if ((cur->*mNode).mNext != NULL)
if ((cur->*mNode).mNext != nullptr)
(((cur->*mNode).mNext)->*mNode).mPrev = cur;
else
mTail = cur;
@@ -204,7 +204,7 @@ template<typename T> T *UdpLinkedList<T>::InsertAfter(T *cur, T *prev)
template<typename T> void UdpLinkedList<T>::DeleteAll()
{
T *cur = First();
while (cur != NULL)
while (cur != nullptr)
{
T *next = Next(cur);
Remove(cur);
@@ -216,7 +216,7 @@ template<typename T> void UdpLinkedList<T>::DeleteAll()
template<typename T> void UdpLinkedList<T>::ReleaseAll()
{
T *cur = First();
while (cur != NULL)
while (cur != nullptr)
{
T *next = Next(cur);
Remove(cur);
@@ -31,7 +31,7 @@ SimpleLogicalPacket::SimpleLogicalPacket(const void *data, int dataLen)
{
mDataLen = dataLen;
mData = new udp_uchar[mDataLen];
if (data != NULL)
if (data != nullptr)
memcpy(mData, data, mDataLen);
}
@@ -66,7 +66,7 @@ void SimpleLogicalPacket::SetDataLen(int len)
GroupLogicalPacket::GroupLogicalPacket() : LogicalPacket()
{
mDataLen = 0;
mData = NULL;
mData = nullptr;
}
GroupLogicalPacket::~GroupLogicalPacket()
@@ -76,13 +76,13 @@ GroupLogicalPacket::~GroupLogicalPacket()
void GroupLogicalPacket::AddPacket(const LogicalPacket *packet)
{
assert(packet != NULL);
assert(packet != nullptr);
AddPacketInternal(packet->GetDataPtr(), packet->GetDataLen(), packet->IsInternalPacket());
}
void GroupLogicalPacket::AddPacket(const void *data, int dataLen)
{
assert(data != NULL);
assert(data != nullptr);
assert(dataLen >= 0);
AddPacketInternal(data, dataLen, false);
}
@@ -152,10 +152,10 @@ PooledLogicalPacket::PooledLogicalPacket(UdpManager *manager, int len)
PooledLogicalPacket::~PooledLogicalPacket()
{
if (mUdpManager != NULL)
if (mUdpManager != nullptr)
{
mUdpManager->PoolDestroyed(this);
mUdpManager = NULL;
mUdpManager = nullptr;
}
delete[] mData;
@@ -168,7 +168,7 @@ void PooledLogicalPacket::AddRef() const
void PooledLogicalPacket::Release() const
{
if (GetRefCount() == 1 && mUdpManager != NULL)
if (GetRefCount() == 1 && mUdpManager != nullptr)
{
// the PoolReturn function steals our reference (ie, we don't release, they don't addref), this is for thread safety reasons
mUdpManager->PoolReturn(const_cast<PooledLogicalPacket *>(this));
@@ -208,9 +208,9 @@ void PooledLogicalPacket::SetDataLen(int len)
void PooledLogicalPacket::SetData(const void *data, int dataLen, const void *data2, int dataLen2)
{
mDataLen = dataLen + dataLen2;
if (data != NULL)
if (data != nullptr)
memcpy(mData, data, dataLen);
if (data2 != NULL)
if (data2 != nullptr)
memcpy(mData + dataLen, data2, dataLen2);
}
@@ -81,7 +81,7 @@ class SimpleLogicalPacket : public LogicalPacket
// it was originally created to allow the internal code to handle reliable data that was sent
// via the Send(char *, int) api call.
public:
SimpleLogicalPacket(const void *data, int dataLen); // data can be NULL if you want to populate it after it is allocated (get the pointer and write to it)
SimpleLogicalPacket(const void *data, int dataLen); // data can be nullptr if you want to populate it after it is allocated (get the pointer and write to it)
virtual void *GetDataPtr();
virtual const void *GetDataPtr() const;
virtual int GetDataLen() const;
@@ -152,7 +152,7 @@ template<typename T> class StructLogicalPacket : public LogicalPacket
// with virtual functions) via this method as they may contain hidden data-members (such as pointers
// to vtables).
public:
StructLogicalPacket(T *initData = NULL);
StructLogicalPacket(T *initData = nullptr);
virtual void *GetDataPtr();
virtual const void *GetDataPtr() const;
virtual int GetDataLen() const;
@@ -226,7 +226,7 @@ class PooledLogicalPacket : public LogicalPacket
protected:
friend class UdpManager;
void TrueRelease() const;
void SetData(const void *data, int dataLen, const void *data2 = NULL, int dataLen2 = 0);
void SetData(const void *data, int dataLen, const void *data2 = nullptr, int dataLen2 = 0);
UdpManager *mUdpManager;
UdpLinkedListMember<PooledLogicalPacket> mAvailableLink; // for available linked list in manager
UdpLinkedListMember<PooledLogicalPacket> mCreatedLink; // for created linked list in manager
@@ -240,7 +240,7 @@ class PooledLogicalPacket : public LogicalPacket
template<int t_quickSize> FixedLogicalPacket<t_quickSize>::FixedLogicalPacket(const void *data, int dataLen)
{
mDataLen = dataLen;
if (data != NULL)
if (data != nullptr)
memcpy(mData, data, mDataLen);
}
@@ -270,7 +270,7 @@ template<int t_quickSize> void FixedLogicalPacket<t_quickSize>::SetDataLen(int l
/////////////////////////////////////////////////////////////////////////
template<typename T> StructLogicalPacket<T>::StructLogicalPacket(T *initData)
{
if (initData != NULL)
if (initData != nullptr)
mStruct = *initData;
}
@@ -111,10 +111,10 @@ UdpManager::UdpManager(const UdpParams *params) : mConnectionList(&UdpConnection
mParams.maxDataHoldSize = udpMin(mParams.maxDataHoldSize, mParams.maxRawPacketSize);
mParams.packetHistoryMax = udpMax(1, mParams.packetHistoryMax);
mPacketHistoryPosition = 0;
mPassThroughData = NULL;
mBackgroundThread = NULL;
mPassThroughData = nullptr;
mBackgroundThread = nullptr;
if (mParams.udpDriver != NULL)
if (mParams.udpDriver != nullptr)
{
mDriver = mParams.udpDriver;
}
@@ -154,7 +154,7 @@ UdpManager::UdpManager(const UdpParams *params) : mConnectionList(&UdpConnection
mSimulateOutgoingQueueBytes = 0;
if (mParams.avoidPriorityQueue)
mPriorityQueue = NULL;
mPriorityQueue = nullptr;
else
mPriorityQueue = new PriorityQueue<UdpConnection, UdpClockStamp>(mParams.maxConnections);
@@ -181,7 +181,7 @@ UdpManager::~UdpManager()
{
// Since the background thread holds a reference to the UdpManager while it is running, this should
// not be possible. The only way it could happen is if somebody released the manager who should not have.
assert(mBackgroundThread == NULL);
assert(mBackgroundThread == nullptr);
// next thing we must do is tell all the connections to disconnect (which severs their link to this dying manager)
// this has to be done first since they will call back into us and have themselves removed from our connection-list/priority-queue/etc
@@ -191,7 +191,7 @@ UdpManager::~UdpManager()
UdpGuard cg(&mConnectionGuard);
UdpConnection *cur = mConnectionList.First();
while (cur != NULL)
while (cur != nullptr)
{
cur->AddRef();
cur->InternalDisconnect(0, UdpConnection::cDisconnectReasonManagerDeleted); // this will cause it to remove us from the mConnectionList
@@ -216,9 +216,9 @@ UdpManager::~UdpManager()
UdpGuard guard(&mPoolGuard);
PooledLogicalPacket *walk = mPoolCreatedList.RemoveHead();
while (walk != NULL)
while (walk != nullptr)
{
walk->mUdpManager = NULL;
walk->mUdpManager = nullptr;
walk = mPoolCreatedList.RemoveHead();
}
// next release the ones we have in our available pool
@@ -232,11 +232,11 @@ UdpManager::~UdpManager()
CloseSocket();
if (mParams.udpDriver == NULL)
if (mParams.udpDriver == nullptr)
{
delete mDriver; // we were not given a driver to use, so we must own this driver we have, so destroy it
}
mDriver = NULL;
mDriver = nullptr;
delete mAddressHashTable;
delete mConnectCodeHashTable;
@@ -295,7 +295,7 @@ void UdpManager::ProcessDisconnectPending()
UdpGuard guard(&mDisconnectPendingGuard);
UdpConnection *entry = mDisconnectPendingList.First();
while (entry != NULL)
while (entry != nullptr)
{
UdpConnection *next = mDisconnectPendingList.Next(entry);
if (entry->GetStatus() == UdpConnection::cStatusDisconnected)
@@ -309,12 +309,12 @@ void UdpManager::ProcessDisconnectPending()
void UdpManager::RemoveConnection(UdpConnection *con)
{
assert(con != NULL); // attemped to remove a NULL connection object
assert(con != nullptr); // attemped to remove a nullptr connection object
// note: it's a bug to Remove a connection object that is already removed...should never be able to happen.
UdpGuard cg(&mConnectionGuard);
if (mPriorityQueue != NULL)
if (mPriorityQueue != nullptr)
{
mPriorityQueue->Remove(con);
}
@@ -326,7 +326,7 @@ void UdpManager::RemoveConnection(UdpConnection *con)
void UdpManager::AddConnection(UdpConnection *con)
{
assert(con != NULL); // attemped to add a NULL connection object
assert(con != nullptr); // attemped to add a nullptr connection object
UdpGuard cg(&mConnectionGuard);
con->AddRef(); // UdpManager keeps a soft reference to the connection (ie. if it sees it is the only one holding a reference, it releases it)
@@ -341,17 +341,17 @@ void UdpManager::FlushAllMultiBuffer()
mConnectionGuard.Enter();
UdpConnection *cur = mConnectionList.First();
if (cur != NULL)
if (cur != nullptr)
cur->AddRef();
mConnectionGuard.Leave();
while (cur != NULL)
while (cur != nullptr)
{
cur->FlushMultiBuffer();
mConnectionGuard.Enter();
UdpConnection *next = mConnectionList.Next(cur);
if (next != NULL)
if (next != nullptr)
next->AddRef();
mConnectionGuard.Leave();
@@ -366,15 +366,15 @@ void UdpManager::DisconnectAll()
mConnectionGuard.Enter();
UdpConnection *cur = mConnectionList.First();
if (cur != NULL)
if (cur != nullptr)
cur->AddRef();
mConnectionGuard.Leave();
while (cur != NULL)
while (cur != nullptr)
{
mConnectionGuard.Enter();
UdpConnection *next = mConnectionList.Next(cur);
if (next != NULL)
if (next != nullptr)
next->AddRef();
mConnectionGuard.Leave();
@@ -392,7 +392,7 @@ void UdpManager::DeliverEvents(int maxProcessingTime)
for (;;)
{
CallbackEvent *ce = EventListPop();
if (ce == NULL)
if (ce == nullptr)
break;
switch(ce->mEventType)
@@ -426,13 +426,13 @@ void UdpManager::DeliverEvents(int maxProcessingTime)
{
{ // guard block
UdpGuard hguard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
mParams.handler->OnConnectRequest(ce->mSource);
}
}
if (ce->mSource->GetHandler() == NULL) // if application did not set a handler, then the connection is considered refused
if (ce->mSource->GetHandler() == nullptr) // if application did not set a handler, then the connection is considered refused
{
ce->mSource->InternalDisconnect(0, UdpConnection::cDisconnectReasonConnectionRefused);
}
@@ -513,7 +513,7 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
PacketHistoryEntry *e = SimulationReceive();
#endif
if (e == NULL)
if (e == nullptr)
{
mLastEmptySocketBufferStamp = CachedClock();
break;
@@ -545,7 +545,7 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
if (giveConnectionsTime)
{
if (mPriorityQueue != NULL)
if (mPriorityQueue != nullptr)
{
// give time to everybody in the priority-queue that needs it
UdpClockStamp curPriority = CachedClock();
@@ -570,10 +570,10 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
mConnectionGuard.Enter();
top = mPriorityQueue->TopRemove(curPriority);
if (top != NULL)
if (top != nullptr)
top->AddRef(); // must always addref connections while inside the connection guard
mConnectionGuard.Leave();
if (top == NULL)
if (top == nullptr)
break;
top->GiveTime(true);
@@ -593,17 +593,17 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
// give time to everybody
mConnectionGuard.Enter();
UdpConnection *cur = mConnectionList.First();
if (cur != NULL)
if (cur != nullptr)
cur->AddRef();
mConnectionGuard.Leave();
while (cur != NULL)
while (cur != nullptr)
{
cur->GiveTime(true);
mConnectionGuard.Enter();
UdpConnection *next = mConnectionList.Next(cur);
if (next != NULL)
if (next != nullptr)
next->AddRef();
mConnectionGuard.Leave();
@@ -621,13 +621,13 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
UdpClockStamp curStamp = CachedClock();
SimulateQueueEntry *entry = mSimulateOutgoingList.First();
while (entry != NULL && curStamp >= mSimulateNextOutgoingTime)
while (entry != nullptr && curStamp >= mSimulateNextOutgoingTime)
{
mSimulateOutgoingList.Remove(entry);
SimulateQueueEntry *next = mSimulateOutgoingList.First();
// simulate a delay before next packet is considered (ie. simple lag)
if (next != NULL)
if (next != nullptr)
{
int latencyDelay = (mSimulation.simulateOutgoingLatency - CachedClockElapsed(next->mQueueTime));
mSimulateNextOutgoingTime = curStamp + latencyDelay;
@@ -644,7 +644,7 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
ActualSendHelper(entry->mData, entry->mDataLen, entry->mIp, entry->mPort);
UdpConnection *con = AddressGetConnection(entry->mIp, entry->mPort);
if (con != NULL)
if (con != nullptr)
{
con->mSimulateOutgoingQueueBytes -= entry->mDataLen;
con->Release();
@@ -664,12 +664,12 @@ UdpConnection *UdpManager::EstablishConnection(const char *serverAddress, int se
{
UdpGuard guard(&mGiveTimeGuard); // probably not needed, I don't see any reason we can't do this while GiveTime is happening in the background...the connection list is protected independently...still, better safe than sorry
assert(serverAddress != NULL);
assert(serverAddress != nullptr);
char useServerAddress[512];
UdpLibrary::UdpMisc::Strncpy(useServerAddress, serverAddress, sizeof(useServerAddress));
char *portPtr = strchr(useServerAddress, ':');
if (portPtr != NULL)
if (portPtr != nullptr)
{
*portPtr++ = 0;
serverPort = atoi(portPtr);
@@ -679,21 +679,21 @@ UdpConnection *UdpManager::EstablishConnection(const char *serverAddress, int se
assert(serverPort != 0); // can't connect to no port
if (mConnectionList.Count() >= mParams.maxConnections)
return(NULL);
return(nullptr);
// get server address
UdpPlatformAddress destIp;
if (!mDriver->GetHostByName(&destIp, useServerAddress))
{
return(NULL); // could not resolve name
return(nullptr); // could not resolve name
}
// first, see if we already have a connection object managing this ip/port, if we do, then fail
UdpConnection *con = AddressGetConnection(destIp, serverPort);
if (con != NULL)
if (con != nullptr)
{
con->Release();
return(NULL); // already connected to this address/port
return(nullptr); // already connected to this address/port
}
return(new UdpConnection(this, destIp, serverPort, timeout));
}
@@ -709,7 +709,7 @@ void UdpManager::GetStats(UdpManagerStatistics *stats)
{
UdpGuard sg(&mStatsGuard);
assert(stats != NULL);
assert(stats != nullptr);
*stats = mManagerStats;
stats->poolAvailable = mPoolAvailableList.Count();
stats->poolCreated = mPoolCreatedList.Count();
@@ -737,10 +737,10 @@ void UdpManager::DumpPacketHistory(const char *filename) const
{
UdpGuard guard(&mGiveTimeGuard);
assert(filename != NULL);
assert(filename != nullptr);
assert(filename[0] != 0);
FILE *file = fopen(filename, "wt");
if (file != NULL)
if (file != nullptr)
{
// dump history of packets...
for (int i = 0; i < mParams.packetHistoryMax; i++)
@@ -789,7 +789,7 @@ UdpManager::PacketHistoryEntry *UdpManager::SimulationReceive()
for (;;)
{
PacketHistoryEntry *entry = ActualReceive();
if (entry == NULL)
if (entry == nullptr)
break;
SimulateQueueEntry *qe = new SimulateQueueEntry(entry->mBuffer, entry->mLen, entry->mIp, entry->mPort, curStamp);
@@ -797,7 +797,7 @@ UdpManager::PacketHistoryEntry *UdpManager::SimulationReceive()
}
SimulateQueueEntry *winner = mSimulateIncomingList.First();
if (winner != NULL && CachedClockElapsed(winner->mQueueTime) >= mSimulation.simulateIncomingLatency)
if (winner != nullptr && CachedClockElapsed(winner->mQueueTime) >= mSimulation.simulateIncomingLatency)
{
mSimulateIncomingList.Remove(winner);
int pos = mPacketHistoryPosition;
@@ -809,14 +809,14 @@ UdpManager::PacketHistoryEntry *UdpManager::SimulationReceive()
delete winner;
return(mPacketHistory[pos]);
}
return(NULL);
return(nullptr);
}
UdpManager::PacketHistoryEntry *UdpManager::ActualReceive()
{
UdpClockStamp curStamp = CachedClock();
if (mSimulation.simulateIncomingByteRate > 0 && curStamp < mSimulateNextIncomingTime)
return(NULL);
return(nullptr);
UdpPlatformAddress fromAddress;
int fromPort = 0;
@@ -855,7 +855,7 @@ UdpManager::PacketHistoryEntry *UdpManager::ActualReceive()
}
return(mPacketHistory[pos]);
}
return(NULL);
return(nullptr);
}
void UdpManager::ActualSend(const udp_uchar *data, int dataLen, UdpPlatformAddress ip, int port)
@@ -876,7 +876,7 @@ void UdpManager::ActualSend(const udp_uchar *data, int dataLen, UdpPlatformAddre
return; // no room, packet gets lost
UdpConnection *con = AddressGetConnection(ip, port);
if (con != NULL)
if (con != nullptr)
{
if (mSimulation.simulateDestinationOverloadLevel > 0 && con->mSimulateOutgoingQueueBytes + dataLen > mSimulation.simulateDestinationOverloadLevel)
{
@@ -928,7 +928,7 @@ void UdpManager::ProcessRawPacket(const PacketHistoryEntry *e)
UdpConnection *con = AddressGetConnection(e->mIp, e->mPort);
if (con == NULL)
if (con == nullptr)
{
if (e->mLen == 0) // len = 0 = ICMP error
{
@@ -946,7 +946,7 @@ void UdpManager::ProcessRawPacket(const PacketHistoryEntry *e)
if (mConnectionList.Count() >= mParams.maxConnections)
return; // can't handle any more connections, so ignore this request entirely
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
UdpConnection *newcon = new UdpConnection(this, e);
CallbackConnectRequest(newcon);
@@ -968,7 +968,7 @@ void UdpManager::ProcessRawPacket(const PacketHistoryEntry *e)
int encryptCode = UdpMisc::GetValue32(ptr);
UdpConnection *con = ConnectCodeGetConnection(connectCode);
if (con != NULL)
if (con != nullptr)
{
if (mParams.allowAddressRemapping || con->mIp == e->mIp)
{
@@ -1025,7 +1025,7 @@ UdpConnection *UdpManager::AddressGetConnection(UdpPlatformAddress ip, int port)
UdpGuard guard(&mConnectionGuard);
UdpConnection *found = mAddressHashTable->FindFirst(AddressHashValue(ip, port));
while (found != NULL)
while (found != nullptr)
{
if (found->mIp == ip && found->mPort == port)
{
@@ -1034,7 +1034,7 @@ UdpConnection *UdpManager::AddressGetConnection(UdpPlatformAddress ip, int port)
}
found = mAddressHashTable->FindNext(found);
}
return(NULL);
return(nullptr);
}
UdpConnection *UdpManager::ConnectCodeGetConnection(int connectCode) const
@@ -1042,7 +1042,7 @@ UdpConnection *UdpManager::ConnectCodeGetConnection(int connectCode) const
UdpGuard guard(&mConnectionGuard);
UdpConnection *found = mConnectCodeHashTable->FindFirst(connectCode);
while (found != NULL)
while (found != nullptr)
{
if (found->mConnectCode == connectCode)
{
@@ -1051,7 +1051,7 @@ UdpConnection *UdpManager::ConnectCodeGetConnection(int connectCode) const
}
found = mConnectCodeHashTable->FindNext(found);
}
return(NULL);
return(nullptr);
}
LogicalPacket *UdpManager::CreatePacket(const void *data, int dataLen, const void *data2, int dataLen2)
@@ -1063,7 +1063,7 @@ LogicalPacket *UdpManager::CreatePacket(const void *data, int dataLen, const voi
{
UdpGuard guard(&mPoolGuard);
PooledLogicalPacket *lp = mPoolAvailableList.RemoveHead();
if (lp == NULL)
if (lp == nullptr)
{
// create a new pooled packet to fulfil request
lp = new PooledLogicalPacket(this, mParams.pooledPacketSize);
@@ -1091,7 +1091,7 @@ void UdpManager::PoolDestroyed(PooledLogicalPacket *packet)
char *UdpManager::GetLocalString(char *buf, int bufLen) const
{
if (bufLen < 22)
return(NULL);
return(nullptr);
UdpPlatformAddress ip = GetLocalIp();
int port = GetLocalPort();
char hold[256];
@@ -1103,7 +1103,7 @@ UdpManager::CallbackEvent *UdpManager::AvailableEventBorrow()
{
UdpGuard guard(&mAvailableEventGuard);
CallbackEvent *ce = mAvailableEventList.RemoveHead();
if (ce == NULL)
if (ce == nullptr)
{
ce = new CallbackEvent();
}
@@ -1127,7 +1127,7 @@ void UdpManager::EventListAppend(CallbackEvent *ce)
{
UdpGuard guard(&mEventListGuard);
mEventList.InsertTail(ce);
if (ce->mPayload != NULL)
if (ce->mPayload != nullptr)
{
mEventListBytes += ce->mPayload->GetDataLen();
}
@@ -1137,7 +1137,7 @@ UdpManager::CallbackEvent *UdpManager::EventListPop()
{
UdpGuard guard(&mEventListGuard);
CallbackEvent *event = mEventList.RemoveHead();
if (event != NULL && event->mPayload != NULL)
if (event != nullptr && event->mPayload != nullptr)
{
mEventListBytes -= event->mPayload->GetDataLen();
}
@@ -1148,7 +1148,7 @@ UdpManager::CallbackEvent *UdpManager::EventListPop()
void UdpManager::ThreadStart()
{
UdpGuard guard(&mThreadGuard);
if (mBackgroundThread == NULL)
if (mBackgroundThread == nullptr)
{
mBackgroundThread = new UdpManagerThread(this, mParams.threadSleepTime);
mBackgroundThread->Start();
@@ -1158,12 +1158,12 @@ void UdpManager::ThreadStart()
void UdpManager::ThreadStop()
{
UdpGuard guard(&mThreadGuard);
if (mBackgroundThread != NULL)
if (mBackgroundThread != nullptr)
{
assert(mRefCount > 1); // caller must hold a reference, and thread must hold a reference, so this should be true. If it asserts, it means the caller is using a UdpManager that it does not hold a reference to.
mBackgroundThread->Stop(true);
mBackgroundThread->Release();
mBackgroundThread = NULL;
mBackgroundThread = nullptr;
}
}
@@ -1256,13 +1256,13 @@ void UdpManager::CallbackConnectRequest(UdpConnection *con)
{
{ // guard block
UdpGuard hguard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
mParams.handler->OnConnectRequest(con);
}
}
if (con->GetHandler() == NULL) // if application did not set a handler, then the connection is considered refused
if (con->GetHandler() == nullptr) // if application did not set a handler, then the connection is considered refused
{
con->InternalDisconnect(0, UdpConnection::cDisconnectReasonConnectionRefused);
}
@@ -1276,8 +1276,8 @@ void UdpManager::CallbackConnectRequest(UdpConnection *con)
UdpManager::CallbackEvent::CallbackEvent()
{
mEventType = cCallbackEventNone;
mSource = NULL;
mPayload = NULL;
mSource = nullptr;
mPayload = nullptr;
mReason = cUdpCorruptionReasonNone;
}
@@ -1291,7 +1291,7 @@ void UdpManager::CallbackEvent::SetEventData(CallbackEventType eventType, UdpCon
mEventType = eventType;
mSource = con;
mSource->AddRef();
if (payload != NULL)
if (payload != nullptr)
{
mPayload = payload;
mPayload->AddRef();
@@ -1300,16 +1300,16 @@ void UdpManager::CallbackEvent::SetEventData(CallbackEventType eventType, UdpCon
void UdpManager::CallbackEvent::ClearEventData()
{
if (mSource != NULL)
if (mSource != nullptr)
{
mSource->Release();
mSource = NULL;
mSource = nullptr;
}
if (mPayload != NULL)
if (mPayload != nullptr)
{
mPayload->Release();
mPayload = NULL;
mPayload = nullptr;
}
}
@@ -178,7 +178,7 @@ struct UdpParams
// pointer equal to your object and the UdpManager will call it as appropriate. The UdpConnection object
// also has a handler mechanism that replaces the other callback functions below, see UdpConnection::SetHandler
// if a handler is specified, the callback function is ignored, even if specified.
// default = NULL (not used)
// default = nullptr (not used)
UdpManagerHandler *handler;
// this is the maximum number of connections that can be established by this manager, any incoming/outgoing connections
@@ -496,7 +496,7 @@ struct UdpParams
// the UdpPlatformDriver object itself and chain the calls on through, plus do whatever else it wants;
// however, that is not required. The application maintains ownership of this object and the object must
// not be destroyed by the application until the UdpManager using it is destroyed.
// default = NULL, meaning the UdpManager it will create it's own UdpPlatformDriver for use.
// default = nullptr, meaning the UdpManager it will create it's own UdpPlatformDriver for use.
UdpDriver *udpDriver;
@@ -642,7 +642,7 @@ class UdpManager : public UdpGuardedRefCount
// will call EstablishConnection, then sit in a loop calling UdpManager::GiveTime and checking to see
// if the status of the returned UdpConnection object is changed from cStatusNegotiating. This allows
// the application to look for the ESC key or timeout an attempted connection.
// This function will return NULL if the manager object has exceeded its maximum number of connections
// This function will return nullptr if the manager object has exceeded its maximum number of connections
// or if the serverAddress cannot be resolved to an IP address
// as is noted in the declaration, it is the responsibility of the application establishing the connection to delete it
// setting the timeout value (in milliseconds) to something greater than 0 will cause the UdpConnection object to change
@@ -685,13 +685,13 @@ class UdpManager : public UdpGuardedRefCount
// a terminated packet.
void DisconnectAll();
// creates a logical packet and populates it with data. data can be NULL, in which case it gives you logical packet
// creates a logical packet and populates it with data. data can be nullptr, in which case it gives you logical packet
// of the size specified, but copies no data into it. If you are using pool management (see Params::poolPacketMax),
// it will give you a packet out of the pool if possible, otherwise it will create a packet for you. When logical
// are packets are needed internally for various things (like reliable channel sends that use the (void *, int) interface)
// they are gotten from this function, so your application can likely take advantage of pooling, even if it never bothers
// to explicitly call this function.
LogicalPacket *CreatePacket(const void *data, int dataLen, const void *data2 = NULL, int dataLen2 = 0);
LogicalPacket *CreatePacket(const void *data, int dataLen, const void *data2 = nullptr, int dataLen2 = 0);
void GetSimulation(UdpSimulationParameters *simulationParameters) const;
void SetSimulation(const UdpSimulationParameters *simulationParameters);
@@ -796,7 +796,7 @@ class UdpManager : public UdpGuardedRefCount
CallbackEvent();
~CallbackEvent();
void SetEventData(CallbackEventType eventType, UdpConnection *con, const LogicalPacket *payload = NULL);
void SetEventData(CallbackEventType eventType, UdpConnection *con, const LogicalPacket *payload = nullptr);
void ClearEventData();
CallbackEventType mEventType;
@@ -926,7 +926,7 @@ inline void UdpManager::SetPriority(UdpConnection *con, UdpClockStamp stamp)
if (stamp < mMinimumScheduledStamp)
stamp = mMinimumScheduledStamp;
if (mPriorityQueue != NULL)
if (mPriorityQueue != nullptr)
{
mPriorityQueue->Add(con, stamp);
}
@@ -1025,7 +1025,7 @@ inline int UdpManager::CachedClockElapsed(UdpClockStamp start)
inline int UdpManager::EncryptUserSupplied(UdpConnection *con, udp_uchar *destData, const udp_uchar *sourceData, int sourceLen)
{
UdpGuard guard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
return(mParams.handler->OnUserSuppliedEncrypt(con, destData, sourceData, sourceLen));
}
@@ -1035,7 +1035,7 @@ inline int UdpManager::EncryptUserSupplied(UdpConnection *con, udp_uchar *destDa
inline int UdpManager::EncryptUserSupplied2(UdpConnection *con, udp_uchar *destData, const udp_uchar *sourceData, int sourceLen)
{
UdpGuard guard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
return(mParams.handler->OnUserSuppliedEncrypt2(con, destData, sourceData, sourceLen));
}
@@ -1045,7 +1045,7 @@ inline int UdpManager::EncryptUserSupplied2(UdpConnection *con, udp_uchar *destD
inline int UdpManager::DecryptUserSupplied(UdpConnection *con, udp_uchar *destData, const udp_uchar *sourceData, int sourceLen)
{
UdpGuard guard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
return(mParams.handler->OnUserSuppliedDecrypt(con, destData, sourceData, sourceLen));
}
@@ -1055,7 +1055,7 @@ inline int UdpManager::DecryptUserSupplied(UdpConnection *con, udp_uchar *destDa
inline int UdpManager::DecryptUserSupplied2(UdpConnection *con, udp_uchar *destData, const udp_uchar *sourceData, int sourceLen)
{
UdpGuard guard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
return(mParams.handler->OnUserSuppliedDecrypt2(con, destData, sourceData, sourceLen));
}
@@ -1070,7 +1070,7 @@ inline int UdpManager::DecryptUserSupplied2(UdpConnection *con, udp_uchar *destD
/////////////////////////////////////////////////////////////////////////////////////////////////////
inline UdpParams::UdpParams(ManagerRole role)
{
handler = NULL;
handler = nullptr;
outgoingBufferSize = 64 * 1024;
incomingBufferSize = 64 * 1024;
packetHistoryMax = 4;
@@ -1103,7 +1103,7 @@ inline UdpParams::UdpParams(ManagerRole role)
reliableOverflowBytes = 0;
lingerDelay = 10;
bindIpAddress[0] = 0;
udpDriver = NULL;
udpDriver = nullptr;
callbackEventPoolMax = 5000;
eventQueuing = false;
threadSleepTime = 20;
@@ -113,19 +113,19 @@ void *UdpMisc::SmartResize(void *ptr, int bytes, int round)
if (bytes == 0)
{
if (ptr != NULL)
if (ptr != nullptr)
{
free((udp_uchar *)ptr - cAlignment);
}
return(NULL);
return(nullptr);
}
udp_uchar *ptr2;
if (ptr == NULL)
if (ptr == nullptr)
{
ptr2 = (udp_uchar *)malloc(bytes + cAlignment);
if (ptr2 == NULL)
return(NULL);
if (ptr2 == nullptr)
return(nullptr);
*(int *)ptr2 = bytes;
return(ptr2 + cAlignment);
}
@@ -135,8 +135,8 @@ void *UdpMisc::SmartResize(void *ptr, int bytes, int round)
return(ptr);
ptr2 = (udp_uchar *)realloc((udp_uchar *)ptr - cAlignment, bytes + cAlignment);
if (ptr2 == NULL)
return(NULL);
if (ptr2 == nullptr)
return(nullptr);
*(int *)ptr2 = bytes;
return(ptr2 + cAlignment);
@@ -199,30 +199,30 @@ LogicalPacket *UdpMisc::CreateQuickLogicalPacket(const void *data, int dataLen,
switch(q)
{
case 0:
tlp = new FixedLogicalPacket<cQuickFactor>(NULL, totalDataLen);
tlp = new FixedLogicalPacket<cQuickFactor>(nullptr, totalDataLen);
break;
case 1:
tlp = new FixedLogicalPacket<cQuickFactor * 2>(NULL, totalDataLen);
tlp = new FixedLogicalPacket<cQuickFactor * 2>(nullptr, totalDataLen);
break;
case 2:
case 3:
tlp = new FixedLogicalPacket<cQuickFactor * 4>(NULL, totalDataLen);
tlp = new FixedLogicalPacket<cQuickFactor * 4>(nullptr, totalDataLen);
break;
case 4:
case 5:
case 6:
case 7:
tlp = new FixedLogicalPacket<cQuickFactor * 8>(NULL, totalDataLen);
tlp = new FixedLogicalPacket<cQuickFactor * 8>(nullptr, totalDataLen);
break;
default:
tlp = new SimpleLogicalPacket(NULL, totalDataLen);
tlp = new SimpleLogicalPacket(nullptr, totalDataLen);
break;
}
udp_uchar *dest = (udp_uchar *)tlp->GetDataPtr();
if (data != NULL)
if (data != nullptr)
memcpy(dest, data, dataLen);
if (data2 != NULL)
if (data2 != nullptr)
memcpy(dest + dataLen, data2, dataLen2);
return(tlp);
}
@@ -57,7 +57,7 @@ class UdpMisc
// memory manager does a little bit of this, but if you know you have an allocation that is likely
// to grow quite a bit, you can set the round'ing size up to a fairly large number and avoid
// unnecessary reallocs at the cost of a little potentially wasted space
// initial allocations are done by passing in ptr==NULL, freeing is done by passing in bytes==0
// initial allocations are done by passing in ptr==nullptr, freeing is done by passing in bytes==0
static void *SmartResize(void *ptr, int bytes, int round = 1);
// the following two functions store values in the buffer as a variable length (B1, 0xffB2B1, 0xffffffB4B3B2B1)
@@ -78,7 +78,7 @@ class UdpMisc
static udp_uint GetValue24(const void *buffer); // gets a 24-bit value from the buffer in big-endian format
static udp_ushort GetValue16(const void *buffer); // gets a 16-bit value from the buffer in big-endian format
static LogicalPacket *CreateQuickLogicalPacket(const void *data, int dataLen, const void *data2 = NULL, int dataLen2 = 0);
static LogicalPacket *CreateQuickLogicalPacket(const void *data, int dataLen, const void *data2 = nullptr, int dataLen2 = 0);
// looks up the specified name and translates it to an IP address
// this is a blocking call that can at times take a significant amount of time, but will generally be fast (less than 300ms)

Some files were not shown because too many files have changed in this diff Show More