Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace NULL -> nullptr in *.cpp #2209

Merged
merged 6 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/analyzer/atsp/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void ATSP::cacheCreate()
void ATSP::cacheDestroy()
{
delete[] pCacheMatrix;
pCacheMatrix = NULL;
pCacheMatrix = nullptr;
}

void ATSP::cacheClear()
Expand Down
6 changes: 3 additions & 3 deletions src/analyzer/atsp/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ bool ATSP::loadFromINIFile(const String& filename)
CString<50, false> key;
CString<50, false> value;

for (section = ini.firstSection; section != NULL; section = section->next)
for (section = ini.firstSection; section != nullptr; section = section->next)
flomnes marked this conversation as resolved.
Show resolved Hide resolved
{
if (section->name == ".general")
{
IniFile::Property* p = section->firstProperty;
for (; p != NULL; p = p->next)
for (; p != nullptr; p = p->next)
flomnes marked this conversation as resolved.
Show resolved Hide resolved
{
key = p->key;
key.toLower();
Expand Down Expand Up @@ -180,7 +180,7 @@ bool ATSP::loadFromINIFile(const String& filename)
info->distribution = Data::XCast::dtBeta;

IniFile::Property* p = section->firstProperty;
for (; p != NULL; p = p->next)
for (; p != nullptr; p = p->next)
flomnes marked this conversation as resolved.
Show resolved Hide resolved
{
key = p->key;
key.toLower();
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/core/any/any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Yuni
Any::Any()
{
pTable = Private::Any::Table<Private::Any::Empty>::Get();
pObject = NULL;
pObject = nullptr;
}

Any::Any(const Any& rhs)
Expand Down Expand Up @@ -59,7 +59,7 @@ void Any::reset()
{
pTable->staticDelete(&pObject);
pTable = Private::Any::Table<Private::Any::Empty>::Get();
pObject = NULL;
pObject = nullptr;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ext/yuni/src/yuni/core/charset/charset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Converter::reset()
{
if (!valid())
return;
iconv((iconv_t)pContext, NULL, NULL, NULL, NULL);
iconv((iconv_t)pContext, nullptr, nullptr, nullptr, nullptr);
}

const char* Converter::Name(Charset::Type type)
Expand Down
2 changes: 1 addition & 1 deletion src/ext/yuni/src/yuni/core/dynamiclibrary/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ bool File::loadFromRawFilename(const AnyString& filename, File::Relocation r, Fi
bool File::hasSymbol(const AnyString& name) const
{
return NullHandle != pHandle
and NULL != reinterpret_cast<Symbol::Handle>(YUNI_DYNLIB_DLSYM(pHandle, name.c_str()));
and nullptr != reinterpret_cast<Symbol::Handle>(YUNI_DYNLIB_DLSYM(pHandle, name.c_str()));
flomnes marked this conversation as resolved.
Show resolved Hide resolved
}

Symbol File::resolve(const AnyString& name) const
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/core/getopt/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ inline Context::Context(Parser& parser) : pParser(parser), pTokenIndex(1), pPara

bool Context::findNextParameter(IOption* option, int argc, char* argv[])
{
assert(option != NULL);
assert(option != nullptr);
flomnes marked this conversation as resolved.
Show resolved Hide resolved

if (not option->requireAdditionalParameter())
{
Expand Down Expand Up @@ -343,7 +343,7 @@ GetOpt::ReturnCode Parser::operator()(int argc, char* argv[])

void Parser::helpUsage(const char* argv0)
{
assert(argv0 != NULL); // just in case
assert(argv0 != nullptr); // just in case
flomnes marked this conversation as resolved.
Show resolved Hide resolved

std::cout.write("Usage: ", 7);
std::cout << ExtractFilenameOnly(argv0);
Expand Down
6 changes: 3 additions & 3 deletions src/ext/yuni/src/yuni/core/system/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ inline bool ReadImpl(const AnyString& name, StringT& out, bool emptyBefore)
if (size != 0)
{
int sizeRequired
= WideCharToMultiByte(CP_UTF8, 0, buffer, (int)size - 1, NULL, 0, NULL, NULL);
= WideCharToMultiByte(CP_UTF8, 0, buffer, (int)size - 1, nullptr, 0, nullptr, nullptr);
if (sizeRequired > 0)
{
out.reserve(out.size() + sizeRequired);
Expand All @@ -55,8 +55,8 @@ inline bool ReadImpl(const AnyString& name, StringT& out, bool emptyBefore)
(int)size - 1,
out.data() + out.size(),
size,
NULL,
NULL);
nullptr,
nullptr);
::free(buffer);
out.resize(out.size() + (uint)sizeRequired);
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/core/system/gettimeofday.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ namespace Yuni
{
int gettimeofday(struct timeval* tv, struct timezone* tz)
{
if (NULL != tv)
if (nullptr != tv)
flomnes marked this conversation as resolved.
Show resolved Hide resolved
{
struct _timeb timebuffer;
_ftime64_s(&timebuffer);
tv->tv_sec = (int64_t)(timebuffer.time);
tv->tv_usec = (int64_t)(timebuffer.millitm * 1000);
}

if (NULL != tz)
if (nullptr != tz)
flomnes marked this conversation as resolved.
Show resolved Hide resolved
{
static int tzflag = 0;
if (!tzflag)
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/core/system/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ uint64_t Total()
int mib[2] = {CTL_HW, HW_MEMSIZE};
uint64_t memory;
size_t len = sizeof(uint64_t);
return (!sysctl(mib, 2, &memory, &len, NULL, 0)) ? memory : (uint64_t)defaultTotal;
return (!sysctl(mib, 2, &memory, &len, nullptr, 0)) ? memory : (uint64_t)defaultTotal;
}

uint64_t Available()
Expand Down Expand Up @@ -298,7 +298,7 @@ bool Usage::update()
int mib[2] = {CTL_HW, HW_MEMSIZE};
size_t len = sizeof(uint64_t);
size_t sttotal;
if (sysctl(mib, 2, &sttotal, &len, NULL, 0))
if (sysctl(mib, 2, &sttotal, &len, nullptr, 0))
{
total = (uint64_t)defaultTotal;
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/core/system/username.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ uint WindowsUsername(char* cstring, uint size)
// The variable `unwsize` contains the final zero
--unwsize;
// Getting the size of the buffer into UTF8
int sizeRequired = WideCharToMultiByte(CP_UTF8, 0, unw, unwsize, NULL, 0, NULL, NULL);
int sizeRequired = WideCharToMultiByte(CP_UTF8, 0, unw, unwsize, nullptr, 0, nullptr, nullptr);
if (sizeRequired > 0)
{
if (static_cast<uint>(sizeRequired) > size)
sizeRequired = size;
WideCharToMultiByte(CP_UTF8, 0, unw, unwsize, cstring, sizeRequired, NULL, NULL);
WideCharToMultiByte(CP_UTF8, 0, unw, unwsize, cstring, sizeRequired, nullptr, nullptr);
return static_cast<uint>(sizeRequired);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/datetime/timestamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ char* FormatTimestampToString(const AnyString& format, int64_t timestamp)
if (timestamp <= 0)
{
#ifdef YUNI_OS_MSVC
timestamp = (int64_t)::_time64(NULL);
timestamp = (int64_t)::_time64(nullptr);
#else
timestamp = (int64_t)::time(NULL);
timestamp = (int64_t)::time(nullptr);
#endif
}

Expand Down
26 changes: 13 additions & 13 deletions src/ext/yuni/src/yuni/io/directory/info/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ class DirInfo final : private Yuni::NonCopyable<DirInfo>
}

const int sizeRequired
= WideCharToMultiByte(CP_UTF8, 0, data.name, -1, NULL, 0, NULL, NULL);
= WideCharToMultiByte(CP_UTF8, 0, data.name, -1, nullptr, 0, nullptr, nullptr);
if (sizeRequired <= 0)
continue;
name.reserve((uint)sizeRequired);
WideCharToMultiByte(
CP_UTF8, 0, data.name, -1, (char*)name.data(), sizeRequired, NULL, NULL);
CP_UTF8, 0, data.name, -1, (char*)name.data(), sizeRequired, nullptr, nullptr);
name.resize(((uint)sizeRequired) - 1);

filename.clear();
Expand Down Expand Up @@ -341,12 +341,12 @@ IteratorData* IteratorDataCreate(const AnyString& folder, uint flags)
data->push(folder);
return data;
}
return NULL;
return nullptr;
}

IteratorData* IteratorDataCopy(const IteratorData* data)
{
return (data) ? (new IteratorData(*data)) : NULL;
return (data) ? (new IteratorData(*data)) : nullptr;
}

void IteratorDataFree(const IteratorData* data)
Expand All @@ -356,52 +356,52 @@ void IteratorDataFree(const IteratorData* data)

IteratorData* IteratorDataNext(IteratorData* data)
{
assert(data != NULL);
assert(data != nullptr);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
if (data->next())
return data;
delete data;
return NULL;
return nullptr;
}

const String& IteratorDataFilename(const IteratorData* data)
{
assert(data != NULL);
assert(data != nullptr);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
return data->dirinfo.front().filename;
}

const String& IteratorDataParentName(const IteratorData* data)
{
assert(data != NULL);
assert(data != nullptr);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
return data->dirinfo.front().parent;
}

const String& IteratorDataName(const IteratorData* data)
{
assert(data != NULL);
assert(data != nullptr);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
return data->dirinfo.front().name;
}

uint64_t IteratorDataSize(const IteratorData* data)
{
assert(data != NULL);
assert(data != nullptr);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
return data->dirinfo.front().size;
}

int64_t IteratorDataModified(const IteratorData* data)
{
assert(data != NULL);
assert(data != nullptr);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
return data->dirinfo.front().modified;
}

bool IteratorDataIsFolder(const IteratorData* data)
{
assert(data != NULL);
assert(data != nullptr);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
return data->dirinfo.front().isFolder;
}

bool IteratorDataIsFile(const IteratorData* data)
{
assert(data != NULL);
assert(data != nullptr);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
return !data->dirinfo.front().isFolder;
}

Expand Down
6 changes: 3 additions & 3 deletions src/ext/yuni/src/yuni/io/directory/iterator/iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Flow TraverseWindowsFolder(const String& filename,
bool files)
{
// Convertir the filename
assert(opts.wbuffer != NULL);
assert(opts.wbuffer != nullptr);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
opts.wbuffer[0] = L'\\';
opts.wbuffer[1] = L'\\';
opts.wbuffer[2] = L'?';
Expand Down Expand Up @@ -199,12 +199,12 @@ Flow TraverseWindowsFolder(const String& filename,
}

const int sizeRequired
= WideCharToMultiByte(CP_UTF8, 0, data.cFileName, -1, NULL, 0, NULL, NULL);
= WideCharToMultiByte(CP_UTF8, 0, data.cFileName, -1, nullptr, 0, nullptr, nullptr);
if (sizeRequired <= 0)
continue;
newName.reserve((uint)sizeRequired);
WideCharToMultiByte(
CP_UTF8, 0, data.cFileName, -1, (char*)newName.data(), sizeRequired, NULL, NULL);
CP_UTF8, 0, data.cFileName, -1, (char*)newName.data(), sizeRequired, nullptr, nullptr);
newName.resize(((uint)sizeRequired) - 1);

newFilename.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/ext/yuni/src/yuni/io/directory/remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static bool RmDirRecursiveInternal(const AnyString& path)
buffer.clear() << path << SEP << (const char*)ep->d_name;
::unlink(buffer.c_str());
}
} while (NULL != (ep = ::readdir(dp)));
} while (nullptr != (ep = ::readdir(dp)));
flomnes marked this conversation as resolved.
Show resolved Hide resolved
}
(void)::closedir(dp);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/io/file/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool Size(const AnyString& filename, uint64_t& value)
}

HANDLE hndl = CreateFileW(
wstr.c_str(), 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
wstr.c_str(), 0, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hndl == INVALID_HANDLE_VALUE)
{
value = 0u;
Expand Down Expand Up @@ -158,7 +158,7 @@ bool GetLastWriteTime(HANDLE hFile)
// Convert the last-write time to local time.
if (!FileTimeToSystemTime(&ftWrite, &stUTC))
return false;
if (!SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal))
if (!SystemTimeToTzSpecificLocalTime(nullptr, &stUTC, &stLocal))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/ext/yuni/src/yuni/io/file/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool Stream::open(const AnyString& filename, int mode)
pFd = ::fopen(filename.c_str(), OpenMode::ToCString(mode));
#endif

return (NULL != pFd);
return (nullptr != pFd);
flomnes marked this conversation as resolved.
Show resolved Hide resolved
}

bool Stream::close()
Expand All @@ -130,7 +130,7 @@ bool Stream::close()
{
if (0 == ::fclose(pFd))
{
pFd = NULL;
pFd = nullptr;
return true;
}
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/ext/yuni/src/yuni/job/job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ IJob::IJob() : pThread(nullptr)

IJob::~IJob()
{
assert(this != NULL and "IJob: Destructor: Oo `this' is null !?");
assert(pThread == NULL and "A job can not be attached to a thread when destroyed");
assert(this != nullptr and "IJob: Destructor: Oo `this' is null !?");
flomnes marked this conversation as resolved.
Show resolved Hide resolved
assert(pThread == nullptr and "A job can not be attached to a thread when destroyed");
flomnes marked this conversation as resolved.
Show resolved Hide resolved
}

bool IJob::suspend(uint delay) const
{
// This method must only be called from a thread
assert(pThread and "Job: The pointer to the attached thread must not be NULL");
assert(pThread and "Job: The pointer to the attached thread must not be nullptr");

// We can suspend the job only if it is running
if (pState == stateRunning)
Expand Down
6 changes: 3 additions & 3 deletions src/ext/yuni/src/yuni/job/queue/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ static inline uint OptimalCPUCount()
return count;
}

QueueService::QueueService() : pStatus(sStopped), pThreads(NULL)
QueueService::QueueService() : pStatus(sStopped), pThreads(nullptr)
{
uint count = OptimalCPUCount();
pMinimumThreadCount = count;
pMaximumThreadCount = count;
}

QueueService::QueueService(bool autostart) : pStatus(sStopped), pThreads(NULL)
QueueService::QueueService(bool autostart) : pStatus(sStopped), pThreads(nullptr)
{
uint count = OptimalCPUCount();
pMinimumThreadCount = count;
Expand Down Expand Up @@ -172,7 +172,7 @@ void QueueService::stop(uint timeout)
return;

threads = (ThreadArray*)pThreads;
pThreads = NULL;
pThreads = nullptr;
pStatus = sStopping;
}

Expand Down
Loading
Loading