summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorGoraf <22941576+Goraf@users.noreply.github.com>2018-02-24 15:32:06 +0100
committerGoraf <22941576+Goraf@users.noreply.github.com>2018-02-24 18:20:46 +0100
commit1c0172cca4f1e90679321912e20436a7f42f122d (patch)
tree77a544d2c09332ec176f42ebcf58a40d9c5d2b93 /utils
parentdff565f40105b20b0e8e4dba1f48ccc9b8e7ff44 (diff)
more nullptr
Diffstat (limited to 'utils')
-rw-r--r--utils/mir_buffer.h28
-rw-r--r--utils/std_string_utils.h4
-rw-r--r--utils/utf8_helpers.h108
3 files changed, 70 insertions, 70 deletions
diff --git a/utils/mir_buffer.h b/utils/mir_buffer.h
index f8cfd41fa4..fae75e2d08 100644
--- a/utils/mir_buffer.h
+++ b/utils/mir_buffer.h
@@ -85,7 +85,7 @@ inline void __bcopy(WCHAR *dest, const char *orig, size_t len)
inline void __bcopy(char *dest, const WCHAR *orig, size_t len)
{
- WideCharToMultiByte(CallService("LangPack/GetCodePage", 0, 0), 0, orig, (int)len, dest, (int)len, NULL, NULL);
+ WideCharToMultiByte(CallService("LangPack/GetCodePage", 0, 0), 0, orig, (int)len, dest, (int)len, nullptr, nullptr);
}
@@ -97,13 +97,13 @@ class Buffer
size_t len;
T *str;
- Buffer() : str(NULL), size(0), len(0)
+ Buffer() : str(nullptr), size(0), len(0)
{
alloc(1);
pack();
}
- Buffer(T in) : str(NULL), size(0), len(0)
+ Buffer(T in) : str(nullptr), size(0), len(0)
{
if (in == NULL)
{
@@ -124,7 +124,7 @@ class Buffer
void pack()
{
- if (str != NULL)
+ if (str != nullptr)
memset(&str[len], 0, sizeof(str[len]));
}
@@ -133,7 +133,7 @@ class Buffer
if (total > size)
{
size = total + 256 - total % 256;
- if (str == NULL)
+ if (str == nullptr)
str = (T *) mir_alloc(size * sizeof(T));
else
str = (T *) mir_realloc(str, size * sizeof(T));
@@ -142,10 +142,10 @@ class Buffer
void free()
{
- if (str != NULL)
+ if (str != nullptr)
{
mir_free(str);
- str = NULL;
+ str = nullptr;
len = size = 0;
}
}
@@ -179,7 +179,7 @@ class Buffer
void append(const char *app, size_t appLen = -1)
{
- if (app == NULL)
+ if (app == nullptr)
return;
if (appLen == -1)
appLen = __blen(app);
@@ -194,7 +194,7 @@ class Buffer
void append(const WCHAR *app, size_t appLen = -1)
{
- if (app == NULL)
+ if (app == nullptr)
return;
if (appLen == -1)
appLen = __blen(app);
@@ -209,7 +209,7 @@ class Buffer
void append(const Buffer<char> &app)
{
- if (app.str == NULL)
+ if (app.str == nullptr)
return;
size_t appLen = app.len;
@@ -304,7 +304,7 @@ class Buffer
void translate()
{
- if (str == NULL || len == 0)
+ if (str == nullptr || len == 0)
return;
str[len] = 0;
@@ -347,14 +347,14 @@ class Buffer
T *detach()
{
T *ret = str;
- str = NULL;
+ str = nullptr;
len = 0;
return ret;
}
void trimRight()
{
- if (str == NULL)
+ if (str == nullptr)
return;
int e;
@@ -368,7 +368,7 @@ class Buffer
void trimLeft()
{
- if (str == NULL)
+ if (str == nullptr)
return;
int s;
diff --git a/utils/std_string_utils.h b/utils/std_string_utils.h
index 6608d7a0d9..ad130d12b1 100644
--- a/utils/std_string_utils.h
+++ b/utils/std_string_utils.h
@@ -56,7 +56,7 @@ namespace utils
namespace number
{
- int random(int min, int max, unsigned int *value = NULL);
+ int random(int min, int max, unsigned int *value = nullptr);
};
namespace text
@@ -72,7 +72,7 @@ namespace utils
std::string source_get_value(std::string* data, unsigned int argument_count, ...);
std::string source_get_value2(std::string* data, const char *term, const char *endings, bool wholeString = false);
std::string source_get_form_data(std::string* data, bool hiddenOnly = false);
- std::string rand_string(int len, const char *chars = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz", unsigned int *number = NULL);
+ std::string rand_string(int len, const char *chars = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz", unsigned int *number = nullptr);
std::string truncate_utf8(const std::string &text, size_t maxLength);
void explode(std::string str, const std::string &separator, std::vector<std::string>* results);
void append_ordinal(unsigned long value, std::string* data);
diff --git a/utils/utf8_helpers.h b/utils/utf8_helpers.h
index 34ebfd5104..d41baa3168 100644
--- a/utils/utf8_helpers.h
+++ b/utils/utf8_helpers.h
@@ -29,14 +29,14 @@ Boston, MA 02111-1307, USA.
class TcharToUtf8
{
public:
- TcharToUtf8(const char *str) : utf8(NULL)
+ TcharToUtf8(const char *str) : utf8(nullptr)
{
- int size = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+ int size = MultiByteToWideChar(CP_ACP, 0, str, -1, nullptr, 0);
if (size <= 0)
throw L"Could not convert string to WCHAR";
WCHAR *tmp = (WCHAR *) mir_alloc(size * sizeof(WCHAR));
- if (tmp == NULL)
+ if (tmp == nullptr)
throw L"mir_alloc returned NULL";
MultiByteToWideChar(CP_ACP, 0, str, -1, tmp, size);
@@ -47,7 +47,7 @@ public:
}
- TcharToUtf8(const WCHAR *str) : utf8(NULL)
+ TcharToUtf8(const WCHAR *str) : utf8(nullptr)
{
init(str);
}
@@ -55,14 +55,14 @@ public:
~TcharToUtf8()
{
- if (utf8 != NULL)
+ if (utf8 != nullptr)
mir_free(utf8);
}
char *detach()
{
char *ret = utf8;
- utf8 = NULL;
+ utf8 = nullptr;
return ret;
}
@@ -86,15 +86,15 @@ private:
void init(const WCHAR *str)
{
- int size = WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL);
+ int size = WideCharToMultiByte(CP_UTF8, 0, str, -1, nullptr, 0, nullptr, nullptr);
if (size <= 0)
throw L"Could not convert string to UTF8";
utf8 = (char *) mir_alloc(size);
- if (utf8 == NULL)
+ if (utf8 == nullptr)
throw L"mir_alloc returned NULL";
- WideCharToMultiByte(CP_UTF8, 0, str, -1, utf8, size, NULL, NULL);
+ WideCharToMultiByte(CP_UTF8, 0, str, -1, utf8, size, nullptr, nullptr);
}
};
@@ -103,17 +103,17 @@ private:
class Utf8ToTchar
{
public:
- Utf8ToTchar(const char *str) : tchar(NULL)
+ Utf8ToTchar(const char *str) : tchar(nullptr)
{
- if (str == NULL)
+ if (str == nullptr)
return;
- int size = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
+ int size = MultiByteToWideChar(CP_UTF8, 0, str, -1, nullptr, 0);
if (size <= 0)
throw L"Could not convert string to WCHAR";
WCHAR *tmp = (WCHAR *) mir_alloc(size * sizeof(WCHAR));
- if (tmp == NULL)
+ if (tmp == nullptr)
throw L"mir_alloc returned NULL";
MultiByteToWideChar(CP_UTF8, 0, str, -1, tmp, size);
@@ -124,7 +124,7 @@ public:
#else
- size = WideCharToMultiByte(CP_ACP, 0, tmp, -1, NULL, 0, NULL, NULL);
+ size = WideCharToMultiByte(CP_ACP, 0, tmp, -1, nullptr, 0, nullptr, nullptr);
if (size <= 0)
{
mir_free(tmp);
@@ -132,13 +132,13 @@ public:
}
tchar = (wchar_t *) mir_alloc(size * sizeof(char));
- if (tchar == NULL)
+ if (tchar == nullptr)
{
mir_free(tmp);
throw L"mir_alloc returned NULL";
}
- WideCharToMultiByte(CP_ACP, 0, tmp, -1, tchar, size, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, tmp, -1, tchar, size, nullptr, nullptr);
mir_free(tmp);
@@ -147,14 +147,14 @@ public:
~Utf8ToTchar()
{
- if (tchar != NULL)
+ if (tchar != nullptr)
mir_free(tchar);
}
wchar_t *detach()
{
wchar_t *ret = tchar;
- tchar = NULL;
+ tchar = nullptr;
return ret;
}
@@ -181,9 +181,9 @@ private:
class CharToTchar
{
public:
- CharToTchar(const char *str) : tchar(NULL)
+ CharToTchar(const char *str) : tchar(nullptr)
{
- if (str == NULL)
+ if (str == nullptr)
return;
#ifdef UNICODE
@@ -201,7 +201,7 @@ public:
~CharToTchar()
{
#ifdef UNICODE
- if (tchar != NULL)
+ if (tchar != nullptr)
mir_free(tchar);
#endif
}
@@ -211,10 +211,10 @@ public:
#ifdef UNICODE
wchar_t *ret = tchar;
#else
- wchar_t *ret = (tchar == NULL ? NULL : mir_strdup(tchar));
+ wchar_t *ret = (tchar == nullptr ? nullptr : mir_strdup(tchar));
#endif
- tchar = NULL;
+ tchar = nullptr;
return ret;
}
@@ -245,9 +245,9 @@ private:
class WcharToTchar
{
public:
- WcharToTchar(const WCHAR *str) : tchar(NULL)
+ WcharToTchar(const WCHAR *str) : tchar(nullptr)
{
- if (str == NULL)
+ if (str == nullptr)
return;
#ifdef UNICODE
@@ -265,7 +265,7 @@ public:
~WcharToTchar()
{
#ifndef UNICODE
- if (tchar != NULL)
+ if (tchar != nullptr)
mir_free(tchar);
#endif
}
@@ -273,12 +273,12 @@ public:
wchar_t *detach()
{
#ifdef UNICODE
- wchar_t *ret = (tchar == NULL ? NULL : mir_wstrdup(tchar));
+ wchar_t *ret = (tchar == nullptr ? nullptr : mir_wstrdup(tchar));
#else
wchar_t *ret = tchar;
#endif
- tchar = NULL;
+ tchar = nullptr;
return ret;
}
@@ -311,9 +311,9 @@ private:
class CharToWchar
{
public:
- CharToWchar(const char *str) : wchar(NULL)
+ CharToWchar(const char *str) : wchar(nullptr)
{
- if (str == NULL)
+ if (str == nullptr)
return;
wchar = mir_a2u(str);
@@ -322,14 +322,14 @@ public:
~CharToWchar()
{
- if (wchar != NULL)
+ if (wchar != nullptr)
mir_free(wchar);
}
WCHAR *detach()
{
WCHAR *ret = wchar;
- wchar = NULL;
+ wchar = nullptr;
return ret;
}
@@ -357,9 +357,9 @@ private:
class TcharToChar
{
public:
- TcharToChar(const wchar_t *str) : val(NULL)
+ TcharToChar(const wchar_t *str) : val(nullptr)
{
- if (str == NULL)
+ if (str == nullptr)
return;
#ifdef UNICODE
@@ -377,7 +377,7 @@ public:
~TcharToChar()
{
#ifdef UNICODE
- if (val != NULL)
+ if (val != nullptr)
mir_free(val);
#endif
}
@@ -387,10 +387,10 @@ public:
#ifdef UNICODE
char *ret = val;
#else
- char *ret = (val == NULL ? NULL : mir_strdup(val));
+ char *ret = (val == nullptr ? nullptr : mir_strdup(val));
#endif
- val = NULL;
+ val = nullptr;
return ret;
}
@@ -421,9 +421,9 @@ private:
class TcharToWchar
{
public:
- TcharToWchar(const wchar_t *str) : val(NULL)
+ TcharToWchar(const wchar_t *str) : val(nullptr)
{
- if (str == NULL)
+ if (str == nullptr)
return;
#ifdef UNICODE
@@ -441,7 +441,7 @@ public:
~TcharToWchar()
{
#ifndef UNICODE
- if (val != NULL)
+ if (val != nullptr)
mir_free(val);
#endif
}
@@ -449,12 +449,12 @@ public:
WCHAR *detach()
{
#ifdef UNICODE
- WCHAR *ret = (val == NULL ? NULL : mir_wstrdup(val));
+ WCHAR *ret = (val == nullptr ? nullptr : mir_wstrdup(val));
#else
WCHAR *ret = val;
#endif
- val = NULL;
+ val = nullptr;
return ret;
}
@@ -487,30 +487,30 @@ private:
class BstrToTchar
{
public:
- BstrToTchar() : bstr(NULL)
+ BstrToTchar() : bstr(nullptr)
#ifndef UNICODE
, tchar(NULL)
#endif
{
}
- BstrToTchar(const WCHAR *str) : bstr(NULL)
+ BstrToTchar(const WCHAR *str) : bstr(nullptr)
#ifndef UNICODE
- , tchar(NULL)
+ , tchar(nullptr)
#endif
{
- if (str == NULL)
+ if (str == nullptr)
return;
bstr = SysAllocString(str);
}
- BstrToTchar(const char *str) : bstr(NULL)
+ BstrToTchar(const char *str) : bstr(nullptr)
#ifndef UNICODE
- , tchar(NULL)
+ , tchar(nullptr)
#endif
{
- if (str == NULL)
+ if (str == nullptr)
return;
bstr = SysAllocString(CharToWchar(str));
@@ -519,7 +519,7 @@ public:
~BstrToTchar()
{
- if (bstr != NULL)
+ if (bstr != nullptr)
SysFreeString(bstr);
#ifndef UNICODE
@@ -530,7 +530,7 @@ public:
BSTR detach()
{
BSTR ret = bstr;
- bstr = NULL;
+ bstr = nullptr;
return ret;
}
@@ -542,7 +542,7 @@ public:
#else
- if (tchar == NULL)
+ if (tchar == nullptr)
tchar = mir_u2a(bstr);
return tchar;
@@ -573,10 +573,10 @@ private:
void freeTchar()
{
- if (tchar != NULL)
+ if (tchar != nullptr)
{
mir_free(tchar);
- tchar = NULL;
+ tchar = nullptr;
}
}