summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJanne Koskinen <janne.p.koskinen@digia.com>2009-06-17 13:42:12 (GMT)
committerJanne Koskinen <janne.p.koskinen@digia.com>2009-06-17 13:42:12 (GMT)
commit2ede08bce669ddb68070ec1344a51b97ddc945d2 (patch)
tree9f26f22af487890efe6671a5a1fe1a6c55b97b12 /src
parent915749c9a2e3a00d26f69077ab35f2e1e4bb23dd (diff)
downloadQt-2ede08bce669ddb68070ec1344a51b97ddc945d2.zip
Qt-2ede08bce669ddb68070ec1344a51b97ddc945d2.tar.gz
Qt-2ede08bce669ddb68070ec1344a51b97ddc945d2.tar.bz2
Revert "Removed accidental allocation in QRingBuffer::clear()"
This reverts commit 85e940d2fa5e8d2caf0d157f214bb826fc392e7b.
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qringbuffer_p.h12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index d4d0af7..a1bfab0 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -62,10 +62,8 @@ class Q_CORE_EXPORT QRingBuffer
{
public:
inline QRingBuffer(int growth = 4096) : basicBlockSize(growth) {
- head = tail = 0;
- tailBuffer = 0;
- bufferSize = 0;
buffers << QByteArray();
+ clear();
}
inline int nextDataBlockSize() const {
@@ -106,12 +104,8 @@ public:
}
inline char *reserve(int bytes) {
- if (isEmpty()) {
- buffers[tailBuffer].resize(qMax(basicBlockSize, bytes));
- bufferSize = tail = bytes;
- return buffers[tailBuffer].data();
- }
bufferSize += bytes;
+
// if there is already enough space, simply return.
if (tail + bytes <= buffers.at(tailBuffer).size()) {
char *writePtr = buffers[tailBuffer].data() + tail;
@@ -204,7 +198,7 @@ public:
}
inline void clear() {
- if(!isEmpty()) {
+ if(!buffers.isEmpty()) {
QByteArray tmp = buffers[0];
buffers.clear();
buffers << tmp;