summaryrefslogtreecommitdiffstats
path: root/src/core/resources
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-08-05 12:10:24 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-08-14 15:18:27 +0200
commit7d2c280081de8ed442b127313db8958325929686 (patch)
tree7bfdc02966478c6a70ed9f683dd190980bf8f734 /src/core/resources
parent6e32ebdab82953c0fc6931a59cbfc299b788f335 (diff)
QFrameAllocator delete sizeof(*ptr) instead of sizeof(T)
This ensure that if T is a base class, we release the right amount of memory. Of course this assumes the allocation was made using the correct subclass. Change-Id: I9bbbc223726f833c09a747279893a28f533bdabf Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/resources')
-rw-r--r--src/core/resources/qframeallocator.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/core/resources/qframeallocator.h b/src/core/resources/qframeallocator.h
index 34f66c1c3..cb5105a14 100644
--- a/src/core/resources/qframeallocator.h
+++ b/src/core/resources/qframeallocator.h
@@ -81,7 +81,7 @@ public:
template<typename T>
void deallocate(T *ptr)
{
- uint allocatorIndex = allocatorIndexFromSize(sizeof(T)) - 1;
+ uint allocatorIndex = allocatorIndexFromSize(sizeof(*ptr)) - 1;
if (allocatorIndex < allocatorIndexFromSize(maxObjectSize())) {
ptr->~T(); // Call destructor
deallocateAtChunck(ptr, allocatorIndex);
@@ -105,7 +105,7 @@ public:
template<typename T>
void deallocateRawMemory(T *ptr)
{
- uint allocatorIndex = allocatorIndexFromSize(sizeof(T)) - 1;
+ uint allocatorIndex = allocatorIndexFromSize(sizeof(*ptr)) - 1;
if (allocatorIndex < allocatorIndexFromSize(maxObjectSize()))
deallocateAtChunck(ptr, allocatorIndex);
}