From: Glenn Watson Date: Tue, 26 Jun 2012 00:01:39 +0000 (+1000) Subject: Remove default allocation size for PODVector. X-Git-Tag: 071012131707~99 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9fd34288efdbb5c77d002408dd83bccbd654292f;p=profile%2Fivi%2Fqtdeclarative.git Remove default allocation size for PODVector. The default increment was 1024, which can waste memory. Remove the default value so that clients must explicitly set the allocation increment. The original bug is no longer relevant, as capture properties are now stored in a linked list rather than a POD vector. Task-number: QTBUG-20285 Change-Id: Iadb0b40af19fed36ccc05249461acc7e870dcbc3 Reviewed-by: Chris Adams --- diff --git a/src/qml/qml/ftw/qpodvector_p.h b/src/qml/qml/ftw/qpodvector_p.h index c966926..d7f51b4 100644 --- a/src/qml/qml/ftw/qpodvector_p.h +++ b/src/qml/qml/ftw/qpodvector_p.h @@ -58,13 +58,13 @@ QT_BEGIN_NAMESPACE -template -class QPODVector +template +class QPODVector { public: QPODVector() : m_count(0), m_capacity(0), m_data(0) {} - ~QPODVector() { if (m_data) ::free(m_data); } + ~QPODVector() { if (m_data) ::free(m_data); } const T &at(int idx) const { return m_data[idx]; @@ -109,8 +109,8 @@ public: int newSize = m_count + count; reserve(newSize); int moveCount = m_count - idx; - if (moveCount) - ::memmove(m_data + idx + count, m_data + idx, + if (moveCount) + ::memmove(m_data + idx + count, m_data + idx, moveCount * sizeof(T)); m_count = newSize; } @@ -118,7 +118,7 @@ public: void remove(int idx, int count = 1) { int moveCount = m_count - (idx + count); if (moveCount) - ::memmove(m_data + idx, m_data + idx + count, + ::memmove(m_data + idx, m_data + idx + count, moveCount * sizeof(T)); m_count -= count; }