mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-10-07 22:13:07 -04:00
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:
@@ -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;
|
||||
|
||||
+15
-15
@@ -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
|
||||
|
||||
+13
-13
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -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;
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
+4
-4
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user