summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjian liang <jianliang79@gmail.com>2015-09-20 23:08:59 +0800
committerjian liang <jianliang79@gmail.com>2015-09-22 23:32:05 +0000
commitbe2e0f75ae2e55f235b34b402b70628a839b7782 (patch)
treeafe4e5a025b9f932e83448658e20c6ef9e3e22e7 /src
parent843199f303652fa2208e50e03987436ca312b791 (diff)
downloadqtbase-be2e0f75ae2e55f235b34b402b70628a839b7782.tar.gz
Free the QFreeList object allocated memory on exit
This memory allocation was introduced in 314c83c0c2f91532654f869b7dc6af1b7e8538da. With a compiler without thread safe statics support mutex.cpp use a function named freelist() to create the global QFreeList object. it will be created when the first time it was accessed, but will never be released. This patch use Q_DESTRUCTOR_FUNCTION to delete this object. Task-number: QTBUG-48359 Change-Id: I4e4716930930aa98630101a1f96de6a7672af9cb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/thread/qmutex.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index 3269ee3ae8..742a572bef 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -571,19 +571,26 @@ FreeList *freelist()
return &list;
}
#else
+static QBasicAtomicPointer<FreeList> freeListPtr;
+
FreeList *freelist()
{
- static QAtomicPointer<FreeList> list;
- FreeList *local = list.loadAcquire();
+ FreeList *local = freeListPtr.loadAcquire();
if (!local) {
local = new FreeList;
- if (!list.testAndSetRelease(0, local)) {
+ if (!freeListPtr.testAndSetRelease(0, local)) {
delete local;
- local = list.loadAcquire();
+ local = freeListPtr.loadAcquire();
}
}
return local;
}
+
+static void qFreeListDeleter()
+{
+ delete freeListPtr.load();
+}
+Q_DESTRUCTOR_FUNCTION(qFreeListDeleter)
#endif
}