summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorBill King <bill.king@nokia.com>2009-12-02 22:41:34 (GMT)
committerBill King <bill.king@nokia.com>2009-12-02 22:41:34 (GMT)
commit82a63405863f527028302ceaeff957f9ee5176e2 (patch)
tree445dc288777f9861611405e21c7e650c52255300 /src/corelib/tools
parent825c7cf9d5d8e83074636c2feeefc15a3062781d (diff)
parentf29f1bb287c6b39bd1270802d1579f1c1d53f905 (diff)
downloadQt-82a63405863f527028302ceaeff957f9ee5176e2.zip
Qt-82a63405863f527028302ceaeff957f9ee5176e2.tar.gz
Qt-82a63405863f527028302ceaeff957f9ee5176e2.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt 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 f0de98d..201e7b3 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++;
}