Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
#include <QtCore/qarraydata.h>
#include <QtCore/private/qnumeric_p.h>
#include <QtCore/private/qtools_p.h>
#include <QtCore/qmath.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qstring.h>
#include <stdlib.h>
Go to the source code of this file.
Functions | |
QT_BEGIN_NAMESPACE qsizetype | qCalculateBlockSize (qsizetype elementCount, qsizetype elementSize, qsizetype headerSize) noexcept |
CalculateGrowingBlockSizeResult | qCalculateGrowingBlockSize (qsizetype elementCount, qsizetype elementSize, qsizetype headerSize) noexcept |
static CalculateGrowingBlockSizeResult | calculateBlockSize (qsizetype capacity, qsizetype objectSize, qsizetype headerSize, QArrayData::AllocationOption option) |
static QArrayData * | allocateData (qsizetype allocSize) |
static AllocationResult | allocateHelper (qsizetype objectSize, qsizetype alignment, qsizetype capacity, QArrayData::AllocationOption option) noexcept |
|
static |
Definition at line 137 of file qarraydata.cpp.
References header().
Referenced by QContiguousCache< T >::QContiguousCache(), allocateHelper(), QContiguousCache< T >::clear(), and QContiguousCache< T >::setCapacity().
|
inlinestaticnoexcept |
Definition at line 157 of file qarraydata.cpp.
References alignment, allocateData(), blockSize, calculateBlockSize(), capacity, QTypedArrayData< T >::dataStart(), header(), headerSize, Q_ASSERT, and Q_UNLIKELY.
Referenced by QArrayData::allocate(), QArrayData::allocate1(), and QArrayData::allocate2().
|
inlinestatic |
Definition at line 119 of file qarraydata.cpp.
References capacity, QArrayData::Grow, headerSize, qCalculateBlockSize(), qCalculateGrowingBlockSize(), and qMax().
Referenced by allocateHelper(), and QArrayData::reallocateUnaligned().
|
noexcept |
Returns the memory block size for a container containing elementCount elements, each of elementSize bytes, plus a header of headerSize bytes. That is, this function returns {elementCount
* elementSize + headerSize}
but unlike the simple calculation, it checks for overflows during the multiplication and the addition.
Both elementCount and headerSize can be zero, but elementSize cannot.
This function returns -1 on overflow or if the memory block size would not fit a qsizetype.
Definition at line 52 of file qarraydata.cpp.
References headerSize, Q_ASSERT, Q_UNLIKELY, qAddOverflow(), and qMulOverflow().
Referenced by calculateBlockSize(), and qCalculateGrowingBlockSize().
|
noexcept |
Returns the memory block size and the number of elements that will fit in that block for a container containing elementCount elements, each of elementSize bytes, plus a header of headerSize bytes. This function assumes the container will grow and pre-allocates a growth factor.
Both elementCount and headerSize can be zero, but elementSize cannot.
This function returns -1 on overflow or if the memory block size would not fit a qsizetype.
Definition at line 85 of file qarraydata.cpp.
References headerSize, Q_UNLIKELY, qCalculateBlockSize(), and qNextPowerOfTwo().
Referenced by calculateBlockSize().