diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qbuffer.cpp | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index 5975e01e76..4b7edd8481 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -61,7 +61,6 @@ public: QByteArray *buf; QByteArray defaultBuf; - int ioIndex; virtual qint64 peek(char *data, qint64 maxSize); virtual QByteArray peek(qint64 maxSize); @@ -157,14 +156,12 @@ QBuffer::QBuffer() { Q_D(QBuffer); d->buf = &d->defaultBuf; - d->ioIndex = 0; } QBuffer::QBuffer(QByteArray *buf) : QIODevice(*new QBufferPrivate) { Q_D(QBuffer); d->buf = buf ? buf : &d->defaultBuf; - d->ioIndex = 0; d->defaultBuf.clear(); } #else @@ -180,7 +177,6 @@ QBuffer::QBuffer(QObject *parent) { Q_D(QBuffer); d->buf = &d->defaultBuf; - d->ioIndex = 0; } /*! @@ -206,7 +202,6 @@ QBuffer::QBuffer(QByteArray *byteArray, QObject *parent) Q_D(QBuffer); d->buf = byteArray ? byteArray : &d->defaultBuf; d->defaultBuf.clear(); - d->ioIndex = 0; } #endif @@ -253,7 +248,6 @@ void QBuffer::setBuffer(QByteArray *byteArray) d->buf = &d->defaultBuf; } d->defaultBuf.clear(); - d->ioIndex = 0; } /*! @@ -312,7 +306,6 @@ void QBuffer::setData(const QByteArray &data) return; } *d->buf = data; - d->ioIndex = 0; } /*! @@ -340,7 +333,6 @@ bool QBuffer::open(OpenMode flags) if ((flags & Truncate) == Truncate) d->buf->resize(0); - d->ioIndex = (flags & Append) == Append ? d->buf->size() : 0; return QIODevice::open(flags); } @@ -390,7 +382,6 @@ bool QBuffer::seek(qint64 pos) qWarning("QBuffer::seek: Invalid pos: %d", int(pos)); return false; } - d->ioIndex = int(pos); return QIODevice::seek(pos); } @@ -420,10 +411,9 @@ bool QBuffer::canReadLine() const qint64 QBuffer::readData(char *data, qint64 len) { Q_D(QBuffer); - if ((len = qMin(len, qint64(d->buf->size()) - d->ioIndex)) <= 0) + if ((len = qMin(len, qint64(d->buf->size()) - pos())) <= 0) return qint64(0); - memcpy(data, d->buf->constData() + d->ioIndex, len); - d->ioIndex += int(len); + memcpy(data, d->buf->constData() + pos(), len); return len; } @@ -433,7 +423,7 @@ qint64 QBuffer::readData(char *data, qint64 len) qint64 QBuffer::writeData(const char *data, qint64 len) { Q_D(QBuffer); - int extraBytes = d->ioIndex + len - d->buf->size(); + int extraBytes = pos() + len - d->buf->size(); if (extraBytes > 0) { // overflow int newSize = d->buf->size() + extraBytes; d->buf->resize(newSize); @@ -443,8 +433,7 @@ qint64 QBuffer::writeData(const char *data, qint64 len) } } - memcpy(d->buf->data() + d->ioIndex, (uchar *)data, int(len)); - d->ioIndex += int(len); + memcpy(d->buf->data() + pos(), (uchar *)data, int(len)); #ifndef QT_NO_QOBJECT d->writtenSinceLastEmit += len; |