summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvector.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-11-04 05:50:05 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-11-04 05:50:05 (GMT)
commit9cfd793625e6582d2fe3eaff7d5dfac3a3fcdff6 (patch)
tree8f44e4adbf0de9308669820b80697e7ed372608d /src/corelib/tools/qvector.cpp
parent48ea5a5c74620f9811debc6bf1e49bf095d30722 (diff)
parent0ced984d3e2cb2a7a1a219ae7a9b09ff4e15a55c (diff)
downloadQt-9cfd793625e6582d2fe3eaff7d5dfac3a3fcdff6.zip
Qt-9cfd793625e6582d2fe3eaff7d5dfac3a3fcdff6.tar.gz
Qt-9cfd793625e6582d2fe3eaff7d5dfac3a3fcdff6.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/corelib/tools/qvector.cpp')
-rw-r--r--src/corelib/tools/qvector.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index 20f3a80..8bb1074 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -45,7 +45,14 @@
QT_BEGIN_NAMESPACE
-QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false };
+static inline int alignmentThreshold()
+{
+ // malloc on 32-bit platforms should return pointers that are 8-byte aligned or more
+ // while on 64-bit platforms they should be 16-byte aligned or more
+ return 2 * sizeof(void*);
+}
+
+QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false, 0 };
QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init)
{
@@ -55,6 +62,26 @@ QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVe
return p;
}
+QVectorData *QVectorData::allocate(int size, int alignment)
+{
+ return static_cast<QVectorData *>(alignment > alignmentThreshold() ? qMallocAligned(size, alignment) : qMalloc(size));
+}
+
+QVectorData *QVectorData::reallocate(QVectorData *x, int newsize, int oldsize, int alignment)
+{
+ if (alignment > alignmentThreshold())
+ return static_cast<QVectorData *>(qReallocAligned(x, newsize, oldsize, alignment));
+ return static_cast<QVectorData *>(qRealloc(x, newsize));
+}
+
+void QVectorData::free(QVectorData *x, int alignment)
+{
+ if (alignment > alignmentThreshold())
+ qFreeAligned(x);
+ else
+ qFree(x);
+}
+
int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive)
{
if (excessive)