En masse NULL -> nullptr replace

This commit is contained in:
Tiger Wang
2014-10-22 20:12:49 -07:00
committed by archshift
parent 2ac3a807b7
commit a26541a7c3
211 changed files with 1767 additions and 1745 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ AString GetOSErrorString( int a_ErrNo)
#ifdef _WIN32
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, a_ErrNo, 0, buffer, ARRAYCOUNT(buffer), NULL);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, a_ErrNo, 0, buffer, ARRAYCOUNT(buffer), nullptr);
Printf(Out, "%d: %s", a_ErrNo, buffer);
if (!Out.empty() && (Out[Out.length() - 1] == '\n'))
{
@@ -25,7 +25,7 @@ AString GetOSErrorString( int a_ErrNo)
#if !defined(__APPLE__) && ( _GNU_SOURCE) && !defined(ANDROID_NDK) // GNU version of strerror_r()
char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer));
if (res != NULL)
if (res != nullptr)
{
Printf(Out, "%d: %s", a_ErrNo, res);
return Out;
+3 -3
View File
@@ -15,8 +15,8 @@
cEvent::cEvent(void)
{
#ifdef _WIN32
m_Event = CreateEvent(NULL, FALSE, FALSE, NULL);
if (m_Event == NULL)
m_Event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (m_Event == nullptr)
{
LOGERROR("cEvent: cannot create event, GLE = %u. Aborting server.", (unsigned)GetLastError());
abort();
@@ -71,7 +71,7 @@ cEvent::~cEvent()
{
sem_destroy(m_Event);
delete m_Event;
m_Event = NULL;
m_Event = nullptr;
}
#endif
}
+11 -11
View File
@@ -17,7 +17,7 @@
cFile::cFile(void) :
#ifdef USE_STDIO_FILE
m_File(NULL)
m_File(nullptr)
#else
m_File(INVALID_HANDLE_VALUE)
#endif // USE_STDIO_FILE
@@ -31,7 +31,7 @@ cFile::cFile(void) :
cFile::cFile(const AString & iFileName, eMode iMode) :
#ifdef USE_STDIO_FILE
m_File(NULL)
m_File(nullptr)
#else
m_File(INVALID_HANDLE_VALUE)
#endif // USE_STDIO_FILE
@@ -64,7 +64,7 @@ bool cFile::Open(const AString & iFileName, eMode iMode)
Close();
}
const char * Mode = NULL;
const char * Mode = nullptr;
switch (iMode)
{
case fmRead: Mode = "rb"; break;
@@ -72,7 +72,7 @@ bool cFile::Open(const AString & iFileName, eMode iMode)
case fmReadWrite: Mode = "rb+"; break;
case fmAppend: Mode = "a+"; break;
}
if (Mode == NULL)
if (Mode == nullptr)
{
ASSERT(!"Unhandled file mode");
return false;
@@ -84,7 +84,7 @@ bool cFile::Open(const AString & iFileName, eMode iMode)
m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), Mode);
#endif // _WIN32
if ((m_File == NULL) && (iMode == fmReadWrite))
if ((m_File == nullptr) && (iMode == fmReadWrite))
{
// Fix for MS not following C spec, opening "a" mode files for writing at the end only
// The file open operation has been tried with "read update", fails if file not found
@@ -98,7 +98,7 @@ bool cFile::Open(const AString & iFileName, eMode iMode)
#endif // _WIN32
}
return (m_File != NULL);
return (m_File != nullptr);
}
@@ -114,7 +114,7 @@ void cFile::Close(void)
}
fclose(m_File);
m_File = NULL;
m_File = nullptr;
}
@@ -123,7 +123,7 @@ void cFile::Close(void)
bool cFile::IsOpen(void) const
{
return (m_File != NULL);
return (m_File != nullptr);
}
@@ -366,7 +366,7 @@ int cFile::GetSize(const AString & a_FileName)
bool cFile::CreateFolder(const AString & a_FolderPath)
{
#ifdef _WIN32
return (CreateDirectoryA(a_FolderPath.c_str(), NULL) != 0);
return (CreateDirectoryA(a_FolderPath.c_str(), nullptr) != 0);
#else
return (mkdir(a_FolderPath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0);
#endif
@@ -415,13 +415,13 @@ AStringVector cFile::GetFolderContents(const AString & a_Folder)
{
Folder = ".";
}
if ((dp = opendir(Folder.c_str())) == NULL)
if ((dp = opendir(Folder.c_str())) == nullptr)
{
LOGERROR("Error (%i) opening directory \"%s\"\n", errno, Folder.c_str());
}
else
{
while ((dirp = readdir(dp)) != NULL)
while ((dirp = readdir(dp)) != nullptr)
{
AllFiles.push_back(dirp->d_name);
}
+7 -7
View File
@@ -11,7 +11,7 @@
cGZipFile::cGZipFile(void) :
m_File(NULL), m_Mode(fmRead)
m_File(nullptr), m_Mode(fmRead)
{
}
@@ -30,14 +30,14 @@ cGZipFile::~cGZipFile()
bool cGZipFile::Open(const AString & a_FileName, eMode a_Mode)
{
if (m_File != NULL)
if (m_File != nullptr)
{
ASSERT(!"A file is already open in this object");
return false;
}
m_File = gzopen(a_FileName.c_str(), (a_Mode == fmRead) ? "r" : "w");
m_Mode = a_Mode;
return (m_File != NULL);
return (m_File != nullptr);
}
@@ -46,10 +46,10 @@ bool cGZipFile::Open(const AString & a_FileName, eMode a_Mode)
void cGZipFile::Close(void)
{
if (m_File != NULL)
if (m_File != nullptr)
{
gzclose(m_File);
m_File = NULL;
m_File = nullptr;
}
}
@@ -59,7 +59,7 @@ void cGZipFile::Close(void)
int cGZipFile::ReadRestOfFile(AString & a_Contents)
{
if (m_File == NULL)
if (m_File == nullptr)
{
ASSERT(!"No file has been opened");
return -1;
@@ -90,7 +90,7 @@ int cGZipFile::ReadRestOfFile(AString & a_Contents)
bool cGZipFile::Write(const char * a_Contents, int a_Size)
{
if (m_File == NULL)
if (m_File == nullptr)
{
ASSERT(!"No file has been opened");
return false;
+1 -1
View File
@@ -214,7 +214,7 @@ void cListenThread::Execute(void)
timeval tv; // On Linux select() doesn't seem to wake up when socket is closed, so let's kinda busy-wait:
tv.tv_sec = 1;
tv.tv_usec = 0;
if (select((int)Highest + 1, &fdRead, NULL, NULL, &tv) == -1)
if (select((int)Highest + 1, &fdRead, nullptr, nullptr, &tv) == -1)
{
LOG("select(R) call failed in cListenThread: \"%s\"", cSocket::GetLastErrorString().c_str());
continue;
+2 -2
View File
@@ -36,7 +36,7 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /*
}
#else
m_Handle = CreateSemaphore(
NULL, // security attribute
nullptr, // security attribute
a_InitialCount, // initial count
a_MaxCount, // maximum count
0 // name (optional)
@@ -98,7 +98,7 @@ void cSemaphore::Signal()
LOG("ERROR: Could not signal cSemaphore. (%i)", errno);
}
#else
ReleaseSemaphore( m_Handle, 1, NULL);
ReleaseSemaphore( m_Handle, 1, nullptr);
#endif
}
+1 -1
View File
@@ -292,7 +292,7 @@ bool cSocket::ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Por
{
// It is not an IP Address string, but rather a regular hostname, resolve:
hostent * hp = gethostbyname(a_HostNameOrAddr.c_str());
if (hp == NULL)
if (hp == nullptr)
{
LOGWARNING("%s: Could not resolve hostname \"%s\"", __FUNCTION__, a_HostNameOrAddr.c_str());
CloseSocket();
+7 -7
View File
@@ -61,7 +61,7 @@ bool cSocketThreads::AddClient(const cSocket & a_Socket, cCallback * a_Client)
// There was an error launching the thread (but it was already logged along with the reason)
LOGERROR("A new cSocketThread failed to start");
delete Thread;
Thread = NULL;
Thread = nullptr;
return false;
}
Thread->AddClient(a_Socket, a_Client);
@@ -233,7 +233,7 @@ bool cSocketThreads::cSocketThread::RemoveClient(const cCallback * a_Client)
// More data to send, shut down reading and wait for the rest to get sent:
m_Slots[i].m_State = sSlot::ssWritingRestOut;
}
m_Slots[i].m_Client = NULL;
m_Slots[i].m_Client = nullptr;
}
// Notify the thread of the change:
@@ -407,7 +407,7 @@ void cSocketThreads::cSocketThread::Execute(void)
timeval Timeout;
Timeout.tv_sec = 5;
Timeout.tv_usec = 0;
if (select((int)Highest + 1, &fdRead, &fdWrite, NULL, &Timeout) == -1)
if (select((int)Highest + 1, &fdRead, &fdWrite, nullptr, &Timeout) == -1)
{
LOG("select() call failed in cSocketThread: \"%s\"", cSocket::GetLastErrorString().c_str());
continue;
@@ -519,7 +519,7 @@ void cSocketThreads::cSocketThread::ReadFromSockets(fd_set * a_Read)
}
else
{
if (m_Slots[i].m_Client != NULL)
if (m_Slots[i].m_Client != nullptr)
{
m_Slots[i].m_Client->DataReceived(Buffer, Received);
}
@@ -545,7 +545,7 @@ void cSocketThreads::cSocketThread::WriteToSockets(fd_set * a_Write)
if (m_Slots[i].m_Outgoing.empty())
{
// Request another chunk of outgoing data:
if (m_Slots[i].m_Client != NULL)
if (m_Slots[i].m_Client != nullptr)
{
AString Data;
m_Slots[i].m_Client->GetOutgoingData(Data);
@@ -573,7 +573,7 @@ void cSocketThreads::cSocketThread::WriteToSockets(fd_set * a_Write)
int Err = cSocket::GetLastError();
LOGWARNING("Error %d while writing to client \"%s\", disconnecting. \"%s\"", Err, m_Slots[i].m_Socket.GetIPString().c_str(), GetOSErrorString(Err).c_str());
m_Slots[i].m_Socket.CloseSocket();
if (m_Slots[i].m_Client != NULL)
if (m_Slots[i].m_Client != nullptr)
{
m_Slots[i].m_Client->SocketClosed();
}
@@ -668,7 +668,7 @@ void cSocketThreads::cSocketThread::QueueOutgoingData(void)
cCSLock Lock(m_Parent->m_CS);
for (int i = 0; i < m_NumSlots; i++)
{
if (m_Slots[i].m_Client != NULL)
if (m_Slots[i].m_Client != nullptr)
{
AString Data;
m_Slots[i].m_Client->GetOutgoingData(Data);
+1 -1
View File
@@ -137,7 +137,7 @@ private:
/** The socket is primarily owned by this object */
cSocket m_Socket;
/** The callback to call for events. May be NULL */
/** The callback to call for events. May be nullptr */
cCallback * m_Client;
/** If sending writes only partial data, the rest is stored here for another send.