aboutsummaryrefslogtreecommitdiff
path: root/common/str.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/str.cpp')
-rw-r--r--common/str.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/common/str.cpp b/common/str.cpp
index 077a493fd0..468d1a6f53 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -28,7 +28,7 @@
namespace Common {
-MemoryPool *g_refCountPool = 0; // FIXME: This is never freed right now
+MemoryPool *g_refCountPool = nullptr; // FIXME: This is never freed right now
static uint32 computeCapacity(uint32 len) {
// By default, for the capacity we use the next multiple of 32
@@ -36,7 +36,7 @@ static uint32 computeCapacity(uint32 len) {
}
String::String(const char *str) : _size(0), _str(_storage) {
- if (str == 0) {
+ if (str == nullptr) {
_storage[0] = 0;
_size = 0;
} else
@@ -64,9 +64,9 @@ void String::initWithCStr(const char *str, uint32 len) {
if (len >= _builtinCapacity) {
// Not enough internal storage, so allocate more
_extern._capacity = computeCapacity(len + 1);
- _extern._refCount = 0;
+ _extern._refCount = nullptr;
_str = new char[_extern._capacity];
- assert(_str != 0);
+ assert(_str != nullptr);
}
// Copy the string into the storage area
@@ -87,7 +87,7 @@ String::String(const String &str)
_extern._capacity = str._extern._capacity;
_str = str._str;
}
- assert(_str != 0);
+ assert(_str != nullptr);
}
String::String(char c)
@@ -165,15 +165,15 @@ void String::ensureCapacity(uint32 new_size, bool keep_old) {
// Set the ref count & capacity if we use an external storage.
// It is important to do this *after* copying any old content,
// else we would override data that has not yet been copied!
- _extern._refCount = 0;
+ _extern._refCount = nullptr;
_extern._capacity = newCapacity;
}
}
void String::incRefCount() const {
assert(!isStorageIntern());
- if (_extern._refCount == 0) {
- if (g_refCountPool == 0) {
+ if (_extern._refCount == nullptr) {
+ if (g_refCountPool == nullptr) {
g_refCountPool = new MemoryPool(sizeof(int));
assert(g_refCountPool);
}
@@ -290,7 +290,7 @@ bool String::hasPrefix(const String &x) const {
}
bool String::hasPrefix(const char *x) const {
- assert(x != 0);
+ assert(x != nullptr);
// Compare x with the start of _str.
const char *y = c_str();
while (*x && *x == *y) {
@@ -324,7 +324,7 @@ bool String::hasSuffix(const String &x) const {
}
bool String::hasSuffix(const char *x) const {
- assert(x != 0);
+ assert(x != nullptr);
// Compare x with the end of _str.
const uint32 x_size = strlen(x);
if (x_size > _size)
@@ -360,16 +360,16 @@ bool String::hasSuffixIgnoreCase(const char *x) const {
}
bool String::contains(const String &x) const {
- return strstr(c_str(), x.c_str()) != NULL;
+ return strstr(c_str(), x.c_str()) != nullptr;
}
bool String::contains(const char *x) const {
- assert(x != 0);
- return strstr(c_str(), x) != NULL;
+ assert(x != nullptr);
+ return strstr(c_str(), x) != nullptr;
}
bool String::contains(char x) const {
- return strchr(c_str(), x) != NULL;
+ return strchr(c_str(), x) != nullptr;
}
uint64 String::asUint64() const {
@@ -647,7 +647,7 @@ bool String::operator==(const String &x) const {
}
bool String::operator==(const char *x) const {
- assert(x != 0);
+ assert(x != nullptr);
return equals(x);
}
@@ -656,7 +656,7 @@ bool String::operator!=(const String &x) const {
}
bool String::operator !=(const char *x) const {
- assert(x != 0);
+ assert(x != nullptr);
return !equals(x);
}
@@ -693,7 +693,7 @@ bool String::equals(const String &x) const {
}
bool String::equals(const char *x) const {
- assert(x != 0);
+ assert(x != nullptr);
return (0 == compareTo(x));
}
@@ -702,7 +702,7 @@ bool String::equalsIgnoreCase(const String &x) const {
}
bool String::equalsIgnoreCase(const char *x) const {
- assert(x != 0);
+ assert(x != nullptr);
return (0 == compareToIgnoreCase(x));
}
@@ -711,7 +711,7 @@ int String::compareTo(const String &x) const {
}
int String::compareTo(const char *x) const {
- assert(x != 0);
+ assert(x != nullptr);
return strcmp(c_str(), x);
}
@@ -720,7 +720,7 @@ int String::compareToIgnoreCase(const String &x) const {
}
int String::compareToIgnoreCase(const char *x) const {
- assert(x != 0);
+ assert(x != nullptr);
return scumm_stricmp(c_str(), x);
}
@@ -852,13 +852,13 @@ bool matchString(const char *str, const char *pat, bool ignoreCase, bool pathMod
assert(str);
assert(pat);
- const char *p = 0;
- const char *q = 0;
+ const char *p = nullptr;
+ const char *q = nullptr;
for (;;) {
if (pathMode && *str == '/') {
- p = 0;
- q = 0;
+ p = nullptr;
+ q = nullptr;
if (*pat == '?')
return false;
}
@@ -874,8 +874,8 @@ bool matchString(const char *str, const char *pat, bool ignoreCase, bool pathMod
// NB: We can't simply check if pat also ended here, because
// the pattern might end with any number of *s.
++pat;
- p = 0;
- q = 0;
+ p = nullptr;
+ q = nullptr;
}
// If pattern ended with * -> match
if (!*pat)