diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-02-21 10:41:54 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-02-26 07:13:18 +0000 |
commit | 499ec43937e926e4f2fa57a9baa455fcb3862262 (patch) | |
tree | 206c90d47387f8322b68f5e3db613189397e1af3 /src/qml/memory | |
parent | 53d1e9ed21d25e65a2f13606af479838f5f21fe7 (diff) |
use nullptr consistently (clang-tidy)
From now on we prefer nullptr instead of 0 to clarify cases where
we are assigning or testing a pointer rather than a numeric zero.
Also, replaced cases where 0 was passed as Qt::KeyboardModifiers
with Qt::NoModifier (clang-tidy replaced them with nullptr, which
waas wrong, so it was just as well to make the tests more readable
rather than to revert those lines).
Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/memory')
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 12 | ||||
-rw-r--r-- | src/qml/memory/qv4mm_p.h | 12 | ||||
-rw-r--r-- | src/qml/memory/qv4mmdefs_p.h | 6 |
3 files changed, 15 insertions, 15 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 9c51013317..cdda0bf7ef 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -186,7 +186,7 @@ struct MemorySegment { } PageReservation pageReservation; - Chunk *base = 0; + Chunk *base = nullptr; quint64 allocatedMap = 0; size_t availableBytes = 0; uint nChunks = 0; @@ -203,14 +203,14 @@ Chunk *MemorySegment::allocate(size_t size) } size_t requiredChunks = (size + sizeof(Chunk) - 1)/sizeof(Chunk); uint sequence = 0; - Chunk *candidate = 0; + Chunk *candidate = nullptr; for (uint i = 0; i < nChunks; ++i) { if (!testBit(i)) { if (!candidate) candidate = base + i; ++sequence; } else { - candidate = 0; + candidate = nullptr; sequence = 0; } if (sequence == requiredChunks) { @@ -221,7 +221,7 @@ Chunk *MemorySegment::allocate(size_t size) return candidate; } } - return 0; + return nullptr; } struct ChunkAllocator { @@ -594,7 +594,7 @@ HeapItem *BlockAllocator::allocate(size_t size, bool forceAllocation) { if (!m) { if (!forceAllocation) - return 0; + return nullptr; Chunk *newChunk = chunkAllocator->allocate(); Q_V4_PROFILE_ALLOC(engine, Chunk::DataSize, Profiling::HeapPage); chunks.push_back(newChunk); @@ -617,7 +617,7 @@ done: void BlockAllocator::sweep() { - nextFree = 0; + nextFree = nullptr; nFree = 0; memset(freeBins, 0, sizeof(freeBins)); diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h index 7dc73bdacc..1ef54ffcc6 100644 --- a/src/qml/memory/qv4mm_p.h +++ b/src/qml/memory/qv4mm_p.h @@ -105,7 +105,7 @@ struct BlockAllocator { void collectGrayItems(MarkStack *markStack); // bump allocations - HeapItem *nextFree = 0; + HeapItem *nextFree = nullptr; size_t nFree = 0; size_t usedSlotsAfterLastSweep = 0; HeapItem *freeBins[NumBins]; @@ -229,7 +229,7 @@ public: { Scope scope(engine); Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic)); - Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : 0)); + Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : nullptr)); Q_UNUSED(prototype); t->d_unchecked()->init(); return t->d(); @@ -240,7 +240,7 @@ public: { Scope scope(engine); Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic)); - Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : 0)); + Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : nullptr)); Q_UNUSED(prototype); t->d_unchecked()->init(arg1); return t->d(); @@ -251,7 +251,7 @@ public: { Scope scope(engine); Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic)); - Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : 0)); + Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : nullptr)); Q_UNUSED(prototype); t->d_unchecked()->init(arg1, arg2); return t->d(); @@ -262,7 +262,7 @@ public: { Scope scope(engine); Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic)); - Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : 0)); + Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : nullptr)); Q_UNUSED(prototype); t->d_unchecked()->init(arg1, arg2, arg3); return t->d(); @@ -273,7 +273,7 @@ public: { Scope scope(engine); Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic)); - Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : 0)); + Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : nullptr)); Q_UNUSED(prototype); t->d_unchecked()->init(arg1, arg2, arg3, arg4); return t->d(); diff --git a/src/qml/memory/qv4mmdefs_p.h b/src/qml/memory/qv4mmdefs_p.h index 4e64ba8118..3e2bae46c2 100644 --- a/src/qml/memory/qv4mmdefs_p.h +++ b/src/qml/memory/qv4mmdefs_p.h @@ -272,9 +272,9 @@ Q_STATIC_ASSERT((1 << Chunk::BitShift) == Chunk::Bits); struct MarkStack { MarkStack(ExecutionEngine *engine); - Heap::Base **top = 0; - Heap::Base **base = 0; - Heap::Base **limit = 0; + Heap::Base **top = nullptr; + Heap::Base **base = nullptr; + Heap::Base **limit = nullptr; ExecutionEngine *engine; void push(Heap::Base *m) { *top = m; |