diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-22 21:09:24 +0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-28 15:27:40 +0100 |
commit | e83bb2fdfc2dc899526c8157fd8b77a68cdde9da (patch) | |
tree | 50a23cf12df52705f254156072269ec4cce04a21 /src/corelib/global/qmalloc.cpp | |
parent | 3f0b969772cf3056ed54349bfe6837d9de2995ea (diff) | |
download | qt4-tools-e83bb2fdfc2dc899526c8157fd8b77a68cdde9da.tar.gz |
Fix Qt containers to properly support types with strict alignments.
QContiguousCache is a new type, so there are no binary compatibility
issues.
QHash and QMap didn't have any public qMalloc / qFree, so the entire
logic is contained in .cpp code. However, since old code will not
inform us of the alignment requirements, we need to add a bit to the
structure to indicate whether strict alignment is in use or not.
QList doesn't require any changes. For small, movable types, they're
all stored in the pointer array itself, so they're aligned. For larger
types, we use new(), so types with stricter requirements should define
their own operator new().
QLinkedList cannot be fixed. It uses new() on the QLinkedListNode,
which contains a T type. Sorry.
QVector did have public qMalloc / qFree. I've moved the calls to the
inner function and made it keep the old calls if the alignment
requirement is below a certain threshold. The idea is that, if it's
above, no one was using QVector anyway.
Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'src/corelib/global/qmalloc.cpp')
-rw-r--r-- | src/corelib/global/qmalloc.cpp | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index db5e5190df..e33f77c998 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -144,9 +144,6 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align // faked-sizeof(void*) is properly aligned for a pointer faked.pptr[-1] = real.ptr; - // and save the actual size just before the pointer - //reinterpret_cast<size_t *>(faked.pptr - 1)[-1] = size; - return faked.ptr; #endif } |