summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvarlengtharray.h
diff options
context:
space:
mode:
authorPeter Kümmel <syntheticpp@gmx.net>2012-10-10 16:35:44 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-28 16:52:40 +0100
commit70a9caf4de9ddac52783a276a6cdd196eb5fef44 (patch)
tree0cde1065579cf0b0d4f43a10ea53e15fb7529ff3 /src/corelib/tools/qvarlengtharray.h
parentff31462e7378fe633cd346b48bb420c7fd2aaff0 (diff)
QVarLengthArray: add squeeze function
Add function to move back data to the stack. Change-Id: Ic78a368459bce68629e29602e4eeae2e1afe398b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r--src/corelib/tools/qvarlengtharray.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 5e57de5767..095e6e929e 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -103,6 +103,7 @@ public:
inline bool isEmpty() const { return (s == 0); }
inline void resize(int size);
inline void clear() { resize(0); }
+ inline void squeeze();
inline int capacity() const { return a; }
inline void reserve(int size);
@@ -244,6 +245,10 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::append(const T *abuf, in
}
template <class T, int Prealloc>
+Q_INLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::squeeze()
+{ realloc(s, s); }
+
+template <class T, int Prealloc>
Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int aalloc)
{
Q_ASSERT(aalloc >= asize);