summaryrefslogtreecommitdiff
path: root/src/textfile_gui.cpp
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-04-10 22:07:06 +0100
committerMichael Lutz <michi@icosahedron.de>2019-04-10 23:22:20 +0200
commit7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch)
tree99f134b7e66367cf11e10bc5061896eab4a3264f /src/textfile_gui.cpp
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/textfile_gui.cpp')
-rw-r--r--src/textfile_gui.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp
index b70d183bd..7a2eb44ca 100644
--- a/src/textfile_gui.cpp
+++ b/src/textfile_gui.cpp
@@ -184,7 +184,7 @@ void TextfileWindow::SetupScrollbars()
/* virtual */ const char *TextfileWindow::NextString()
{
- if (this->search_iterator >= this->lines.size()) return NULL;
+ if (this->search_iterator >= this->lines.size()) return nullptr;
return this->lines[this->search_iterator++];
}
@@ -214,13 +214,13 @@ void TextfileWindow::SetupScrollbars()
* After the call, it contains the size of the uncompressed
* data.
*
- * When decompressing fails, *bufp is set to NULL and *sizep to 0. The
+ * When decompressing fails, *bufp is set to nullptr and *sizep to 0. The
* compressed buffer passed in is still freed in this case.
*/
static void Gunzip(byte **bufp, size_t *sizep)
{
static const int BLOCKSIZE = 8192;
- byte *buf = NULL;
+ byte *buf = nullptr;
size_t alloc_size = 0;
z_stream z;
int res;
@@ -250,7 +250,7 @@ static void Gunzip(byte **bufp, size_t *sizep)
*sizep = alloc_size - z.avail_out;
} else {
/* Something went wrong */
- *bufp = NULL;
+ *bufp = nullptr;
*sizep = 0;
free(buf);
}
@@ -270,13 +270,13 @@ static void Gunzip(byte **bufp, size_t *sizep)
* After the call, it contains the size of the uncompressed
* data.
*
- * When decompressing fails, *bufp is set to NULL and *sizep to 0. The
+ * When decompressing fails, *bufp is set to nullptr and *sizep to 0. The
* compressed buffer passed in is still freed in this case.
*/
static void Xunzip(byte **bufp, size_t *sizep)
{
static const int BLOCKSIZE = 8192;
- byte *buf = NULL;
+ byte *buf = nullptr;
size_t alloc_size = 0;
lzma_stream z = LZMA_STREAM_INIT;
int res;
@@ -304,7 +304,7 @@ static void Xunzip(byte **bufp, size_t *sizep)
*sizep = alloc_size - z.avail_out;
} else {
/* Something went wrong */
- *bufp = NULL;
+ *bufp = nullptr;
*sizep = 0;
free(buf);
}
@@ -317,14 +317,14 @@ static void Xunzip(byte **bufp, size_t *sizep)
*/
/* virtual */ void TextfileWindow::LoadTextfile(const char *textfile, Subdirectory dir)
{
- if (textfile == NULL) return;
+ if (textfile == nullptr) return;
this->lines.clear();
/* Get text from file */
size_t filesize;
FILE *handle = FioFOpenFile(textfile, "rb", dir, &filesize);
- if (handle == NULL) return;
+ if (handle == nullptr) return;
this->text = ReallocT(this->text, filesize);
size_t read = fread(this->text, 1, filesize, handle);
@@ -334,7 +334,7 @@ static void Xunzip(byte **bufp, size_t *sizep)
#if defined(WITH_ZLIB) || defined(WITH_LIBLZMA)
const char *suffix = strrchr(textfile, '.');
- if (suffix == NULL) return;
+ if (suffix == nullptr) return;
#endif
#if defined(WITH_ZLIB)
@@ -381,7 +381,7 @@ static void Xunzip(byte **bufp, size_t *sizep)
* @param type The type of the textfile to search for.
* @param dir The subdirectory to search in.
* @param filename The filename of the content to look for.
- * @return The path to the textfile, \c NULL otherwise.
+ * @return The path to the textfile, \c nullptr otherwise.
*/
const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
{
@@ -394,13 +394,13 @@ const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filenam
const char *prefix = prefixes[type];
- if (filename == NULL) return NULL;
+ if (filename == nullptr) return nullptr;
static char file_path[MAX_PATH];
strecpy(file_path, filename, lastof(file_path));
char *slash = strrchr(file_path, PATHSEPCHAR);
- if (slash == NULL) return NULL;
+ if (slash == nullptr) return nullptr;
static const char * const exts[] = {
"txt",
@@ -422,5 +422,5 @@ const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filenam
seprintf(slash + 1, lastof(file_path), "%s.%s", prefix, exts[i]);
if (FioCheckFileExists(file_path, dir)) return file_path;
}
- return NULL;
+ return nullptr;
}