Convert to C++ nullptr from NULL.

This commit is contained in:
Jonathan Naylor
2025-03-14 12:13:11 +00:00
parent 43f8b2f6f0
commit cf15f42a0f
98 changed files with 1340 additions and 1340 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 by SASANO Takayoshi JG1UAA
* Copyright (C) 2020,2025 by SASANO Takayoshi JG1UAA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@ bool CUserDB::lookup(unsigned int id, class CUserDBentry *entry)
m_mutex.lock();
try {
if (entry != NULL)
if (entry != nullptr)
*entry = m_table.at(id);
else
(void)m_table.at(id);
@@ -59,7 +59,7 @@ bool CUserDB::load(std::string const& filename)
LogInfo("Loading ID lookup table from %s", filename.c_str());
FILE* fp = ::fopen(filename.c_str(), "rt");
if (fp == NULL) {
if (fp == nullptr) {
LogWarning("Cannot open ID lookup file - %s", filename.c_str());
return false;
}
@@ -71,7 +71,7 @@ bool CUserDB::load(std::string const& filename)
// set index for entries
char buffer[256U];
if (::fgets(buffer, sizeof(buffer), fp) == NULL) {
if (::fgets(buffer, sizeof(buffer), fp) == nullptr) {
LogWarning("ID lookup file has no entry - %s", filename.c_str());
m_mutex.unlock();
::fclose(fp);
@@ -86,7 +86,7 @@ bool CUserDB::load(std::string const& filename)
::rewind(fp);
}
while (::fgets(buffer, sizeof(buffer), fp) != NULL) {
while (::fgets(buffer, sizeof(buffer), fp) != nullptr) {
if (buffer[0U] != '#')
parse(buffer, index);
}
@@ -109,7 +109,7 @@ bool CUserDB::makeindex(char* buf, std::unordered_map<std::string, int>& index)
// Remove the old index
index.clear();
for (i = 0, p1 = tokenize(buf, &p2); p1 != NULL;
for (i = 0, p1 = tokenize(buf, &p2); p1 != nullptr;
i++, p1 = tokenize(p2, &p2)) {
// create [column keyword] - [column number] table
@@ -133,7 +133,7 @@ void CUserDB::parse(char* buf, std::unordered_map<std::string, int>& index)
std::unordered_map<std::string, char*> ptr;
unsigned int id;
for (i = 0, p1 = tokenize(buf, &p2); p1 != NULL;
for (i = 0, p1 = tokenize(buf, &p2); p1 != nullptr;
i++, p1 = tokenize(p2, &p2)) {
for (auto it = index.begin(); it != index.end(); it++) {
@@ -175,10 +175,10 @@ void CUserDB::toupper_string(char* str)
char* CUserDB::tokenize(char* str, char** next)
{
if (*str == '\0')
return NULL;
return nullptr;
char* p = ::strpbrk(str, ",\t\r\n");
if (p == NULL) {
if (p == nullptr) {
*next = str + ::strlen(str);
} else {
*p = '\0';