Fix valgrind support in the memory manager
authorLars Knoll <lars.knoll@theqtcompany.com>
Fri, 12 Dec 2014 14:29:22 +0000 (15:29 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Fri, 19 Dec 2014 15:30:08 +0000 (16:30 +0100)
Fix compilation and ensure the memory manager
doesn't create bogus warnings.

Change-Id: I78ccfc7a11944f3275b7c03f6005874a561fa977
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4mm.cpp

index 4aebda0..e2d1d19 100644 (file)
@@ -214,6 +214,7 @@ void sweepChunk(const MemoryManager::Data::Chunk &chunk, ChunkSweepData *sweepDa
             sweepData->tail = m->nextFreeRef();
         }
     }
+    *sweepData->tail = 0;
 #ifdef V4_USE_VALGRIND
     VALGRIND_ENABLE_ERROR_REPORTING;
 #endif
@@ -454,14 +455,22 @@ void MemoryManager::sweep(bool lastSweep)
             chunkIter = m_d->heapChunks.erase(chunkIter);
             continue;
         } else if (chunkSweepData[i].head) {
+#ifdef V4_USE_VALGRIND
+            VALGRIND_DISABLE_ERROR_REPORTING;
+#endif
             *tails[pos] = chunkSweepData[i].head;
+#ifdef V4_USE_VALGRIND
+            VALGRIND_ENABLE_ERROR_REPORTING;
+#endif
             tails[pos] = chunkSweepData[i].tail;
         }
         ++chunkIter;
     }
-    for (int pos = 0; pos < MemoryManager::Data::MaxItemSize/16; ++pos)
-        *tails[pos] = 0;
+
 #ifdef V4_USE_VALGRIND
+    VALGRIND_DISABLE_ERROR_REPORTING;
+    for (int pos = 0; pos < MemoryManager::Data::MaxItemSize/16; ++pos)
+        Q_ASSERT(*tails[pos] == 0);
     VALGRIND_ENABLE_ERROR_REPORTING;
 #endif