summaryrefslogtreecommitdiff
path: root/src/os/macosx
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/os/macosx
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/os/macosx')
-rw-r--r--src/os/macosx/crashlog_osx.cpp16
-rw-r--r--src/os/macosx/splash.cpp16
-rw-r--r--src/os/macosx/string_osx.cpp34
3 files changed, 33 insertions, 33 deletions
diff --git a/src/os/macosx/crashlog_osx.cpp b/src/os/macosx/crashlog_osx.cpp
index c1b321340..16c029639 100644
--- a/src/os/macosx/crashlog_osx.cpp
+++ b/src/os/macosx/crashlog_osx.cpp
@@ -66,7 +66,7 @@ class CrashLogOSX : public CrashLog {
" Machine: %s\n"
" Min Ver: %d\n",
ver_maj, ver_min, ver_bug,
- arch != NULL ? arch->description : "unknown",
+ arch != nullptr ? arch->description : "unknown",
MAC_OS_X_VERSION_MIN_REQUIRED
);
}
@@ -79,7 +79,7 @@ class CrashLogOSX : public CrashLog {
" Message: %s\n\n",
strsignal(this->signum),
this->signum,
- message == NULL ? "<none>" : message
+ message == nullptr ? "<none>" : message
);
}
@@ -99,14 +99,14 @@ class CrashLogOSX : public CrashLog {
frame = (void **)__builtin_frame_address(0);
#endif
- for (int i = 0; frame != NULL && i < MAX_STACK_FRAMES; i++) {
+ for (int i = 0; frame != nullptr && i < MAX_STACK_FRAMES; i++) {
/* Get IP for current stack frame. */
#if defined(__ppc__) || defined(__ppc64__)
void *ip = frame[2];
#else
void *ip = frame[1];
#endif
- if (ip == NULL) break;
+ if (ip == nullptr) break;
/* Print running index. */
buffer += seprintf(buffer, last, " [%02d]", i);
@@ -118,7 +118,7 @@ class CrashLogOSX : public CrashLog {
if (dl_valid && dli.dli_fname) {
/* Valid image name? Extract filename from the complete path. */
const char *s = strrchr(dli.dli_fname, '/');
- if (s != NULL) {
+ if (s != nullptr) {
fname = s + 1;
} else {
fname = dli.dli_fname;
@@ -128,13 +128,13 @@ class CrashLogOSX : public CrashLog {
buffer += seprintf(buffer, last, " %-20s " PRINTF_PTR, fname, (uintptr_t)ip);
/* Print function offset if information is available. */
- if (dl_valid && dli.dli_sname != NULL && dli.dli_saddr != NULL) {
+ if (dl_valid && dli.dli_sname != nullptr && dli.dli_saddr != nullptr) {
/* Try to demangle a possible C++ symbol. */
int status = -1;
- char *func_name = abi::__cxa_demangle(dli.dli_sname, NULL, 0, &status);
+ char *func_name = abi::__cxa_demangle(dli.dli_sname, nullptr, 0, &status);
long int offset = (intptr_t)ip - (intptr_t)dli.dli_saddr;
- buffer += seprintf(buffer, last, " (%s + %ld)", func_name != NULL ? func_name : dli.dli_sname, offset);
+ buffer += seprintf(buffer, last, " (%s + %ld)", func_name != nullptr ? func_name : dli.dli_sname, offset);
free(func_name);
}
diff --git a/src/os/macosx/splash.cpp b/src/os/macosx/splash.cpp
index eadb78510..1ddb165b3 100644
--- a/src/os/macosx/splash.cpp
+++ b/src/os/macosx/splash.cpp
@@ -54,7 +54,7 @@ static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
void DisplaySplashImage()
{
FILE *f = FioFOpenFile(SPLASH_IMAGE_FILE, "r", BASESET_DIR);
- if (f == NULL) return;
+ if (f == nullptr) return;
png_byte header[8];
fread(header, sizeof(png_byte), 8, f);
@@ -63,23 +63,23 @@ void DisplaySplashImage()
return;
}
- png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp) NULL, png_my_error, png_my_warning);
+ png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp) nullptr, png_my_error, png_my_warning);
- if (png_ptr == NULL) {
+ if (png_ptr == nullptr) {
fclose(f);
return;
}
png_infop info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL) {
- png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
+ if (info_ptr == nullptr) {
+ png_destroy_read_struct(&png_ptr, (png_infopp)nullptr, (png_infopp)nullptr);
fclose(f);
return;
}
png_infop end_info = png_create_info_struct(png_ptr);
- if (end_info == NULL) {
- png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ if (end_info == nullptr) {
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)nullptr);
fclose(f);
return;
}
@@ -93,7 +93,7 @@ void DisplaySplashImage()
png_init_io(png_ptr, f);
png_set_sig_bytes(png_ptr, 8);
- png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
+ png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, nullptr);
uint width = png_get_image_width(png_ptr, info_ptr);
uint height = png_get_image_height(png_ptr, info_ptr);
diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp
index 580be3520..6d90b91a8 100644
--- a/src/os/macosx/string_osx.cpp
+++ b/src/os/macosx/string_osx.cpp
@@ -22,7 +22,7 @@
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
/** Cached current locale. */
-static CFLocaleRef _osx_locale = NULL;
+static CFLocaleRef _osx_locale = nullptr;
/** CoreText cache for font information, cleared when OTTD changes fonts. */
static CTFontRef _font_cache[FS_END];
@@ -125,21 +125,21 @@ static CGFloat SpriteFontGetWidth(void *ref_con)
}
static CTRunDelegateCallbacks _sprite_font_callback = {
- kCTRunDelegateCurrentVersion, NULL, NULL, NULL,
+ kCTRunDelegateCurrentVersion, nullptr, nullptr, nullptr,
&SpriteFontGetWidth
};
/* static */ ParagraphLayouter *CoreTextParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping)
{
- if (!MacOSVersionIsAtLeast(10, 5, 0)) return NULL;
+ if (!MacOSVersionIsAtLeast(10, 5, 0)) return nullptr;
/* Can't layout an empty string. */
ptrdiff_t length = buff_end - buff;
- if (length == 0) return NULL;
+ if (length == 0) return nullptr;
/* Can't layout our in-built sprite fonts. */
for (const auto &i : fontMapping) {
- if (i.second->fc->IsBuiltInFont()) return NULL;
+ if (i.second->fc->IsBuiltInFont()) return nullptr;
}
/* Make attributed string with embedded font information. */
@@ -156,10 +156,10 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
for (const auto &i : fontMapping) {
if (i.first - last == 0) continue;
- if (_font_cache[i.second->fc->GetSize()] == NULL) {
+ if (_font_cache[i.second->fc->GetSize()] == nullptr) {
/* Cache font information. */
CFStringRef font_name = CFStringCreateWithCString(kCFAllocatorDefault, i.second->fc->GetFontName(), kCFStringEncodingUTF8);
- _font_cache[i.second->fc->GetSize()] = CTFontCreateWithName(font_name, i.second->fc->GetFontSize(), NULL);
+ _font_cache[i.second->fc->GetSize()] = CTFontCreateWithName(font_name, i.second->fc->GetFontSize(), nullptr);
CFRelease(font_name);
}
CFAttributedStringSetAttribute(str, CFRangeMake(last, i.first - last), kCTFontAttributeName, _font_cache[i.second->fc->GetSize()]);
@@ -185,12 +185,12 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
CTTypesetterRef typesetter = CTTypesetterCreateWithAttributedString(str);
CFRelease(str);
- return typesetter != NULL ? new CoreTextParagraphLayout(typesetter, buff, length, fontMapping) : NULL;
+ return typesetter != nullptr ? new CoreTextParagraphLayout(typesetter, buff, length, fontMapping) : nullptr;
}
/* virtual */ std::unique_ptr<const ParagraphLayouter::Line> CoreTextParagraphLayout::NextLine(int max_width)
{
- if (this->cur_offset >= this->length) return NULL;
+ if (this->cur_offset >= this->length) return nullptr;
/* Get line break position, trying word breaking first and breaking somewhere if that doesn't work. */
CFIndex len = CTTypesetterSuggestLineBreak(this->typesetter, this->cur_offset, max_width);
@@ -200,7 +200,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
CTLineRef line = CTTypesetterCreateLine(this->typesetter, CFRangeMake(this->cur_offset, len));
this->cur_offset += len;
- return std::unique_ptr<const Line>(line != NULL ? new CoreTextLine(line, this->font_map, this->text_buffer) : NULL);
+ return std::unique_ptr<const Line>(line != nullptr ? new CoreTextLine(line, this->font_map, this->text_buffer) : nullptr);
}
CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff) : font(font)
@@ -233,7 +233,7 @@ CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font
this->positions[i * 2 + 1] = pts[i].y;
}
}
- this->total_advance = (int)CTRunGetTypographicBounds(run, CFRangeMake(0, 0), NULL, NULL, NULL);
+ this->total_advance = (int)CTRunGetTypographicBounds(run, CFRangeMake(0, 0), nullptr, nullptr, nullptr);
this->positions[this->glyphs.size() * 2] = this->positions[0] + this->total_advance;
}
@@ -271,9 +271,9 @@ int CoreTextParagraphLayout::CoreTextLine::GetWidth() const
/** Delete CoreText font reference for a specific font size. */
void MacOSResetScriptCache(FontSize size)
{
- if (_font_cache[size] != NULL) {
+ if (_font_cache[size] != nullptr) {
CFRelease(_font_cache[size]);
- _font_cache[size] = NULL;
+ _font_cache[size] = nullptr;
}
}
@@ -282,7 +282,7 @@ void MacOSSetCurrentLocaleName(const char *iso_code)
{
if (!MacOSVersionIsAtLeast(10, 5, 0)) return;
- if (_osx_locale != NULL) CFRelease(_osx_locale);
+ if (_osx_locale != nullptr) CFRelease(_osx_locale);
CFStringRef iso = CFStringCreateWithCString(kCFAllocatorNull, iso_code, kCFStringEncodingUTF8);
_osx_locale = CFLocaleCreate(kCFAllocatorDefault, iso);
@@ -425,7 +425,7 @@ int MacOSStringCompare(const char *s1, const char *s2)
/* static */ StringIterator *OSXStringIterator::Create()
{
- if (!MacOSVersionIsAtLeast(10, 5, 0)) return NULL;
+ if (!MacOSVersionIsAtLeast(10, 5, 0)) return nullptr;
return new OSXStringIterator();
}
@@ -441,11 +441,11 @@ int MacOSStringCompare(const char *s1, const char *s2)
/* static */ StringIterator *OSXStringIterator::Create()
{
- return NULL;
+ return nullptr;
}
/* static */ ParagraphLayouter *CoreTextParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping)
{
- return NULL;
+ return nullptr;
}
#endif /* (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) */