Fix QRingBuffer::readPointerAtPosition()
Fix condition to allow return a valid pointer when head != 0. Change-Id: I5215f7dfc44924016c2d9b67ab2d9935b5164d7a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
parent
00dce1cc00
commit
7cc893b216
@ -90,7 +90,7 @@ public:
|
||||
|
||||
// special case: it is in the first buffer
|
||||
int nextDataBlockSizeValue = nextDataBlockSize();
|
||||
if (pos - head < nextDataBlockSizeValue) {
|
||||
if (pos < nextDataBlockSizeValue) {
|
||||
length = nextDataBlockSizeValue - pos;
|
||||
return buffers.at(0).constData() + head + pos;
|
||||
}
|
||||
|
@ -111,6 +111,13 @@ void tst_QRingBuffer::readPointerAtPositionWithHead()
|
||||
buf2 = ringBuffer.readPointerAtPosition(0, length);
|
||||
QCOMPARE(length, qint64(0));
|
||||
QVERIFY(buf2 == 0);
|
||||
|
||||
// check buffer with 2 blocks
|
||||
memcpy(ringBuffer.reserve(4), "0123", 4);
|
||||
ringBuffer.append(QByteArray("45678", 5));
|
||||
ringBuffer.free(3);
|
||||
buf2 = ringBuffer.readPointerAtPosition(1, length);
|
||||
QCOMPARE(length, qint64(5));
|
||||
}
|
||||
|
||||
void tst_QRingBuffer::readPointerAtPositionEmptyRead()
|
||||
|
Loading…
Reference in New Issue
Block a user