summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-14 15:04:18 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-06-07 17:19:16 +0200
commitb4ead572501179244aa036e7a590fa7536929f2b (patch)
treef1e706b221e78e294b3169965c005df768730203 /src/corelib/global
parent327bfdb671e0e263c6fb027133a54985a65194c4 (diff)
Move away from using 0 as a pointer constant
Cleans up most of corelib to use nullptr or default enums where appropriate. Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qglobal.cpp2
-rw-r--r--src/corelib/global/qlogging.cpp14
-rw-r--r--src/corelib/global/qmalloc.cpp8
3 files changed, 12 insertions, 12 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index be01e5a605..897f92a4ea 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -3612,7 +3612,7 @@ bool qEnvironmentVariableIsSet(const char *varName) noexcept
(void)getenv_s(&requiredSize, 0, 0, varName);
return requiredSize != 0;
#else
- return ::getenv(varName) != 0;
+ return ::getenv(varName) != nullptr;
#endif
}
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 292a459e5d..49411306c2 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1100,8 +1100,8 @@ Q_DECLARE_TYPEINFO(QMessagePattern::BacktraceParams, Q_MOVABLE_TYPE);
QBasicMutex QMessagePattern::mutex;
QMessagePattern::QMessagePattern()
- : literals(0)
- , tokens(0)
+ : literals(nullptr)
+ , tokens(nullptr)
, fromEnvironment(false)
{
#ifndef QT_BOOTSTRAPPED
@@ -1121,9 +1121,9 @@ QMessagePattern::~QMessagePattern()
for (int i = 0; literals[i]; ++i)
delete [] literals[i];
delete [] literals;
- literals = 0;
+ literals = nullptr;
delete [] tokens;
- tokens = 0;
+ tokens = nullptr;
}
void QMessagePattern::setPattern(const QString &pattern)
@@ -1173,7 +1173,7 @@ void QMessagePattern::setPattern(const QString &pattern)
// tokenizer
QVarLengthArray<const char*> literalsVar;
tokens = new const char*[lexemes.size() + 1];
- tokens[lexemes.size()] = 0;
+ tokens[lexemes.size()] = nullptr;
bool nestedIfError = false;
bool inIf = false;
@@ -1280,7 +1280,7 @@ void QMessagePattern::setPattern(const QString &pattern)
qt_message_print(error);
literals = new const char*[literalsVar.size() + 1];
- literals[literalsVar.size()] = 0;
+ literals[literalsVar.size()] = nullptr;
memcpy(literals, literalsVar.constData(), literalsVar.size() * sizeof(const char*));
}
@@ -1406,7 +1406,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
#endif
// we do not convert file, function, line literals to local encoding due to overhead
- for (int i = 0; pattern->tokens[i] != 0; ++i) {
+ for (int i = 0; pattern->tokens[i]; ++i) {
const char *token = pattern->tokens[i];
if (token == endifTokenC) {
skip = false;
diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp
index 05676a0da2..b071c1df62 100644
--- a/src/corelib/global/qmalloc.cpp
+++ b/src/corelib/global/qmalloc.cpp
@@ -74,18 +74,18 @@ void *qRealloc(void *ptr, size_t size)
void *qMallocAligned(size_t size, size_t alignment)
{
- return qReallocAligned(0, size, 0, alignment);
+ return qReallocAligned(nullptr, size, 0, alignment);
}
void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t alignment)
{
// fake an aligned allocation
- void *actualptr = oldptr ? static_cast<void **>(oldptr)[-1] : 0;
+ void *actualptr = oldptr ? static_cast<void **>(oldptr)[-1] : nullptr;
if (alignment <= sizeof(void*)) {
// special, fast case
void **newptr = static_cast<void **>(realloc(actualptr, newsize + sizeof(void*)));
if (!newptr)
- return 0;
+ return nullptr;
if (newptr == actualptr) {
// realloc succeeded without reallocating
return oldptr;
@@ -105,7 +105,7 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
void *real = realloc(actualptr, newsize + alignment);
if (!real)
- return 0;
+ return nullptr;
quintptr faked = reinterpret_cast<quintptr>(real) + alignment;
faked &= ~(alignment - 1);