diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-01 22:34:17 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-01 22:34:17 (GMT) |
commit | 01ea458a0c568d9e08133290f23c74a9fbbcb994 (patch) | |
tree | 9c638d416706084c08d3fe76f6ba6a119441b2d1 /src/corelib | |
parent | 8e2b95b1115bc07f81d0fa22cc2929bb28d3e9bb (diff) | |
parent | ef51033ad135450dd2a0f5efc641b330f8ef63b9 (diff) | |
download | Qt-01ea458a0c568d9e08133290f23c74a9fbbcb994.zip Qt-01ea458a0c568d9e08133290f23c74a9fbbcb994.tar.gz Qt-01ea458a0c568d9e08133290f23c74a9fbbcb994.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
Doc: Fixing typo
Fix QTBUG-14640:oci performance problem with qlonglong
32bit => 16bit conversion has 4byte-aligned output.
Fix gcc bug in qReallocAligned
Prevented threading related crash in OpenGL module.
Fix possible crash in QStaticText and QDeclarativeTextLayout
Fix QTBUG-14132 oracle (xe) stored procedures with bind variables get errors
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qmalloc.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index 090998c..028a0a5 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -90,8 +90,6 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align return newptr + 1; } - union { void *ptr; void **pptr; quintptr n; } real, faked; - // qMalloc returns pointers aligned at least at sizeof(size_t) boundaries // but usually more (8- or 16-byte boundaries). // So we overallocate by alignment-sizeof(size_t) bytes, so we're guaranteed to find a @@ -100,19 +98,21 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align // However, we need to store the actual pointer, so we need to allocate actually size + // alignment anyway. - real.ptr = qRealloc(actualptr, newsize + alignment); - if (!real.ptr) + void *real = qRealloc(actualptr, newsize + alignment); + if (!real) return 0; - faked.n = real.n + alignment; - faked.n &= ~(alignment - 1); + quintptr faked = reinterpret_cast<quintptr>(real) + alignment; + faked &= ~(alignment - 1); + + void **faked_ptr = reinterpret_cast<void **>(faked); // now save the value of the real pointer at faked-sizeof(void*) // by construction, alignment > sizeof(void*) and is a power of 2, so // faked-sizeof(void*) is properly aligned for a pointer - faked.pptr[-1] = real.ptr; + faked_ptr[-1] = real; - return faked.ptr; + return faked_ptr; } void qFreeAligned(void *ptr) |