diff options
author | Lars Knoll <lars.knoll@qt.io> | 2019-11-14 16:31:07 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-07-06 21:31:01 +0200 |
commit | 215ca735341b9487826023a7983382851ce8bf26 (patch) | |
tree | 3de5500d47fecff4d92a6f1e0ac83419739b2f50 /src/corelib/tools/qarraydata.h | |
parent | ded37aedc91f8b9460da62baaa4d0e651f19eada (diff) |
Allow allocating more than 2G items in a vector
Also adjust qCalculateBlockSize() to be able to handle large
allocations.
QVector::length() is currently still limited to 2G items, that will
get changed in a later commit.
Change-Id: I3a92fbfd7f281d30844c5fafa3b9a474bc347c19
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qarraydata.h')
-rw-r--r-- | src/corelib/tools/qarraydata.h | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index c1f9656707..89f267ac49 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -62,14 +62,14 @@ struct Q_CORE_EXPORT QArrayData QBasicAtomicInt ref_; uint flags; - uint alloc; + qsizetype alloc; - inline size_t allocatedCapacity() noexcept + inline qsizetype allocatedCapacity() noexcept { return alloc; } - inline size_t constAllocatedCapacity() const noexcept + inline qsizetype constAllocatedCapacity() const noexcept { return alloc; } @@ -100,7 +100,7 @@ struct Q_CORE_EXPORT QArrayData return ref_.loadRelaxed() > 1; } - size_t detachCapacity(size_t newSize) const noexcept + qsizetype detachCapacity(qsizetype newSize) const noexcept { if (flags & CapacityReserved && newSize < constAllocatedCapacity()) return constAllocatedCapacity(); @@ -119,12 +119,12 @@ struct Q_CORE_EXPORT QArrayData #if defined(Q_CC_GNU) __attribute__((__malloc__)) #endif - static void *allocate(QArrayData **pdata, size_t objectSize, size_t alignment, - size_t capacity, ArrayOptions options = DefaultAllocationFlags) noexcept; + static void *allocate(QArrayData **pdata, qsizetype objectSize, qsizetype alignment, + qsizetype capacity, ArrayOptions options = DefaultAllocationFlags) noexcept; Q_REQUIRED_RESULT static QPair<QArrayData *, void *> reallocateUnaligned(QArrayData *data, void *dataPointer, - size_t objectSize, size_t newCapacity, ArrayOptions newOptions = DefaultAllocationFlags) Q_DECL_NOTHROW; - static void deallocate(QArrayData *data, size_t objectSize, - size_t alignment) noexcept; + qsizetype objectSize, qsizetype newCapacity, ArrayOptions newOptions = DefaultAllocationFlags) noexcept; + static void deallocate(QArrayData *data, qsizetype objectSize, + qsizetype alignment) noexcept; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QArrayData::ArrayOptions) @@ -202,7 +202,7 @@ struct QTypedArrayData class AlignmentDummy { QArrayData header; T data; }; - Q_REQUIRED_RESULT static QPair<QTypedArrayData *, T *> allocate(size_t capacity, + Q_REQUIRED_RESULT static QPair<QTypedArrayData *, T *> allocate(qsizetype capacity, ArrayOptions options = DefaultAllocationFlags) { static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); @@ -215,7 +215,7 @@ struct QTypedArrayData } static QPair<QTypedArrayData *, T *> - reallocateUnaligned(QTypedArrayData *data, T *dataPointer, size_t capacity, + reallocateUnaligned(QTypedArrayData *data, T *dataPointer, qsizetype capacity, ArrayOptions options = DefaultAllocationFlags) { static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); |