diff options
| author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-10-02 20:21:29 +0300 |
|---|---|---|
| committer | Alex Trotsenko <alex1973tr@gmail.com> | 2021-10-03 21:01:51 +0300 |
| commit | a8823db57839f0a690f1cd488e2a268871aeca68 (patch) | |
| tree | ed005ca0339f78b93832b4de652050811c910fd0 /src/corelib/tools/qringbuffer.cpp | |
| parent | 9a3f4afb700bb4fb6c4d26120de71fb61ffab032 (diff) | |
QRingBuffer: port internals from int to qsizetype
Since Qt6, QByteArray uses qsizetype as an integral type for offsets
and sizes. In order to support large blocks, we have to migrate to
that as well.
Change-Id: I2c2983129d6a2e0a1e8078cc41d446a26e27288c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qringbuffer.cpp')
| -rw-r--r-- | src/corelib/tools/qringbuffer.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp index 311058a776c..09b0336145f 100644 --- a/src/corelib/tools/qringbuffer.cpp +++ b/src/corelib/tools/qringbuffer.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE -void QRingChunk::allocate(int alloc) +void QRingChunk::allocate(qsizetype alloc) { Q_ASSERT(alloc > 0 && size() == 0); @@ -56,7 +56,7 @@ void QRingChunk::detach() { Q_ASSERT(isShared()); - const int chunkSize = size(); + const qsizetype chunkSize = size(); QByteArray x(chunkSize, Qt::Uninitialized); ::memcpy(x.data(), chunk.constData() + headOffset, chunkSize); chunk = std::move(x); @@ -145,8 +145,8 @@ char *QRingBuffer::reserve(qint64 bytes) { Q_ASSERT(bytes > 0 && bytes < MaxByteArraySize); - const int chunkSize = qMax(basicBlockSize, int(bytes)); - int tail = 0; + const qsizetype chunkSize = qMax(qint64(basicBlockSize), bytes); + qsizetype tail = 0; if (bufferSize == 0) { if (buffers.isEmpty()) buffers.append(QRingChunk(chunkSize)); @@ -175,7 +175,7 @@ char *QRingBuffer::reserveFront(qint64 bytes) { Q_ASSERT(bytes > 0 && bytes < MaxByteArraySize); - const int chunkSize = qMax(basicBlockSize, int(bytes)); + const qsizetype chunkSize = qMax(qint64(basicBlockSize), bytes); if (bufferSize == 0) { if (buffers.isEmpty()) buffers.prepend(QRingChunk(chunkSize)); @@ -204,7 +204,7 @@ void QRingBuffer::chop(qint64 bytes) Q_ASSERT(bytes <= bufferSize); while (bytes > 0) { - const qint64 chunkSize = buffers.constLast().size(); + const qsizetype chunkSize = buffers.constLast().size(); if (buffers.size() == 1 || chunkSize > bytes) { QRingChunk &chunk = buffers.last(); |
