summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-12-03 08:39:08 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-12-03 08:39:08 (GMT)
commite1ef51cdddf4187ab68d09f42438e45a6bbf85f4 (patch)
treee1a59bdb9e3695f43064b6fa7f6ab33d5ef359ca /src/corelib/tools
parentb495786061febf5e4c6baddbd6443f44f142c627 (diff)
parent82a63405863f527028302ceaeff957f9ee5176e2 (diff)
downloadQt-e1ef51cdddf4187ab68d09f42438e45a6bbf85f4.zip
Qt-e1ef51cdddf4187ab68d09f42438e45a6bbf85f4.tar.gz
Qt-e1ef51cdddf4187ab68d09f42438e45a6bbf85f4.tar.bz2
Merge remote branch 'mainline/4.6' into 4.6
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qvector.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 9f10202..e00cf3f 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -324,7 +324,7 @@ void QVector<T>::detach_helper()
{ realloc(d->size, d->alloc); }
template <typename T>
void QVector<T>::reserve(int asize)
-{ if (asize > d->alloc || d->ref != 1) realloc(d->size, asize); d->capacity = 1; }
+{ if (asize > d->alloc) realloc(d->size, asize); if (d->ref == 1) d->capacity = 1; }
template <typename T>
void QVector<T>::resize(int asize)
{ realloc(asize, (asize > d->alloc || (!d->capacity && asize < d->size && asize < (d->alloc >> 1))) ?
@@ -441,6 +441,7 @@ void QVector<T>::free(Data *x)
template <typename T>
void QVector<T>::realloc(int asize, int aalloc)
{
+ Q_ASSERT(asize <= aalloc);
T *pOld;
T *pNew;
union { QVectorData *d; Data *p; } x;
@@ -496,7 +497,8 @@ void QVector<T>::realloc(int asize, int aalloc)
pOld = p->array + x.d->size;
pNew = x.p->array + x.d->size;
// copy objects from the old array into the new array
- while (x.d->size < qMin(asize, d->size)) {
+ const int toMove = qMin(asize, d->size);
+ while (x.d->size < toMove) {
new (pNew++) T(*pOld++);
x.d->size++;
}