aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-04-03 12:35:26 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-04 17:26:20 +0200
commit873f927fe225e2da9870997c73497c528e77e210 (patch)
tree7c597c80d8945d8768ee2847e306dd40a1b4ed81 /src/qml/jsruntime
parent8e556778c8324c61ddf5842e457c873c1b5aac02 (diff)
Make the destroy method optional
This allows us to avoid calling a destructor on objects that don't require one. After the memberData change this should be most objects. Also fix a bug where we didn't call the destroy() method on large objects, potentially leaking memory. Change-Id: I1708055d568d85b0a3876899d35e8c3eb92dd222 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4mm.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp
index 70992a2323..ca2ccd33f7 100644
--- a/src/qml/jsruntime/qv4mm.cpp
+++ b/src/qml/jsruntime/qv4mm.cpp
@@ -224,9 +224,7 @@ Managed *MemoryManager::alloc(std::size_t size)
std::sort(m_d->heapChunks.begin(), m_d->heapChunks.end());
char *chunk = (char *)allocation.memory.base();
char *end = chunk + allocation.memory.size() - size;
-#ifndef QT_NO_DEBUG
- memset(chunk, 0, allocation.memory.size());
-#endif
+
Managed **last = &m_d->smallItems[pos];
while (chunk <= end) {
Managed *o = reinterpret_cast<Managed *>(chunk);
@@ -361,6 +359,8 @@ void MemoryManager::sweep(bool lastSweep)
i = i->next;
continue;
}
+ if (m->internalClass->vtable->destroy)
+ m->internalClass->vtable->destroy(m);
*last = i->next;
free(i);
@@ -400,7 +400,8 @@ void MemoryManager::sweep(char *chunkStart, std::size_t chunkSize, size_t size)
#ifdef V4_USE_VALGRIND
VALGRIND_ENABLE_ERROR_REPORTING;
#endif
- m->internalClass->vtable->destroy(m);
+ if (m->internalClass->vtable->destroy)
+ m->internalClass->vtable->destroy(m);
memset(m, 0, size);
m->setNextFree(*f);