diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-05-27 23:05:41 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-05-27 23:06:01 (GMT) |
commit | 85fa83ac89367bf4f3a85d038ef64a362aa8377e (patch) | |
tree | 706bc6aa64be436480d0d6a0c5603ff31186bfbb /src/corelib/tools/qvarlengtharray.h | |
parent | 103e1e8ea5e8879f2bb97e008840a212b3004a51 (diff) | |
parent | 8f011df08139bea59c12ae0804969334a9374dc8 (diff) | |
download | Qt-85fa83ac89367bf4f3a85d038ef64a362aa8377e.zip Qt-85fa83ac89367bf4f3a85d038ef64a362aa8377e.tar.gz Qt-85fa83ac89367bf4f3a85d038ef64a362aa8377e.tar.bz2 |
Merge remote branch 'origin/4.6' into qt-4.7-from-4.6
Conflicts:
demos/spectrum/app/engine.h
demos/spectrum/app/mainwidget.h
demos/spectrum/app/settingsdialog.h
demos/spectrum/app/spectrograph.h
demos/spectrum/app/spectrumanalyser.h
demos/spectrum/app/tonegenerator.h
demos/spectrum/app/tonegeneratordialog.h
demos/spectrum/app/utils.h
demos/spectrum/app/waveform.h
tests/auto/qtextcodec/tst_qtextcodec.cpp
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 9773d4b..bfede94 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -132,9 +132,9 @@ private: friend class QPodList<T, Prealloc>; void realloc(int size, int alloc); - int a; - int s; - T *ptr; + int a; // capacity + int s; // size + T *ptr; // data union { // ### Qt 5: Use 'Prealloc * sizeof(T)' as array size char array[sizeof(qint64) * (((Prealloc * sizeof(T)) / sizeof(qint64)) + 1)]; @@ -197,8 +197,8 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a Q_ASSERT(aalloc >= asize); T *oldPtr = ptr; int osize = s; - // s = asize; + const int copySize = qMin(asize, osize); if (aalloc != a) { ptr = reinterpret_cast<T *>(qMalloc(aalloc * sizeof(T))); Q_CHECK_PTR(ptr); @@ -209,7 +209,6 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a if (QTypeInfo<T>::isStatic) { QT_TRY { // copy all the old elements - const int copySize = qMin(asize, osize); while (s < copySize) { new (ptr+s) T(*(oldPtr+s)); (oldPtr+s)->~T(); @@ -225,19 +224,19 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a QT_RETHROW; } } else { - qMemCopy(ptr, oldPtr, qMin(asize, osize) * sizeof(T)); + qMemCopy(ptr, oldPtr, copySize * sizeof(T)); } } else { ptr = oldPtr; return; } } + s = copySize; if (QTypeInfo<T>::isComplex) { + // destroy remaining old objects while (osize > asize) (oldPtr+(--osize))->~T(); - if (!QTypeInfo<T>::isStatic) - s = osize; } if (oldPtr != reinterpret_cast<T *>(array) && oldPtr != ptr) |