aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4executableallocator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4executableallocator.cpp')
-rw-r--r--src/qml/jsruntime/qv4executableallocator.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4executableallocator.cpp b/src/qml/jsruntime/qv4executableallocator.cpp
index 2e80f3a611..e539d62d54 100644
--- a/src/qml/jsruntime/qv4executableallocator.cpp
+++ b/src/qml/jsruntime/qv4executableallocator.cpp
@@ -52,6 +52,14 @@ void *ExecutableAllocator::Allocation::start() const
return reinterpret_cast<void*>(addr);
}
+void ExecutableAllocator::Allocation::deallocate(ExecutableAllocator *allocator)
+{
+ if (isValid())
+ allocator->free(this);
+ else
+ delete this;
+}
+
ExecutableAllocator::Allocation *ExecutableAllocator::Allocation::split(size_t dividingSize)
{
Allocation *remainder = new Allocation;
@@ -117,7 +125,8 @@ ExecutableAllocator::ChunkOfPages::~ChunkOfPages()
Allocation *alloc = firstAllocation;
while (alloc) {
Allocation *next = alloc->next;
- delete alloc;
+ if (alloc->isValid())
+ delete alloc;
alloc = next;
}
pages->deallocate();
@@ -142,6 +151,12 @@ ExecutableAllocator::ExecutableAllocator()
ExecutableAllocator::~ExecutableAllocator()
{
+ foreach (ChunkOfPages *chunk, chunks) {
+ for (Allocation *allocation = chunk->firstAllocation; allocation; allocation = allocation->next)
+ if (!allocation->free)
+ allocation->invalidate();
+ }
+
qDeleteAll(chunks);
}