Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qarraydata.cpp File Reference

(2ebd327712b23b1ec136bc613ef60076cbc1b803)

#include <QtCore/qalloc.h>
#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>
Include dependency graph for qarraydata.cpp:

Go to the source code of this file.

Classes

struct  AlignedQArrayData

Functions

QT_BEGIN_NAMESPACE qsizetype qCalculateBlockSize (qsizetype elementCount, qsizetype elementSize, qsizetype headerSize) noexcept
CalculateGrowingBlockSizeResult qCalculateGrowingBlockSize (qsizetype elementCount, qsizetype elementSize, qsizetype headerSize) noexcept
static qsizetype calculateHeaderSize (qsizetype alignment)
static CalculateGrowingBlockSizeResult calculateBlockSize (qsizetype capacity, qsizetype objectSize, qsizetype headerSize, QArrayData::AllocationOption option)
static voidallocateHelper (QArrayData **dptr, qsizetype objectSize, qsizetype alignment, qsizetype capacity, QArrayData::AllocationOption option) noexcept

Function Documentation

◆ allocateHelper()

void * allocateHelper ( QArrayData ** dptr,
qsizetype objectSize,
qsizetype alignment,
qsizetype capacity,
QArrayData::AllocationOption option )
inlinestaticnoexcept

Definition at line 161 of file qarraydata.cpp.

◆ calculateBlockSize()

CalculateGrowingBlockSizeResult calculateBlockSize ( qsizetype capacity,
qsizetype objectSize,
qsizetype headerSize,
QArrayData::AllocationOption option )
inlinestatic

Definition at line 142 of file qarraydata.cpp.

◆ calculateHeaderSize()

qsizetype calculateHeaderSize ( qsizetype alignment)
static

Definition at line 116 of file qarraydata.cpp.

◆ qCalculateBlockSize()

QT_BEGIN_NAMESPACE qsizetype qCalculateBlockSize ( qsizetype elementCount,
qsizetype elementSize,
qsizetype headerSize )
noexcept
Since
5.7

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 53 of file qarraydata.cpp.

◆ qCalculateGrowingBlockSize()

CalculateGrowingBlockSizeResult qCalculateGrowingBlockSize ( qsizetype elementCount,
qsizetype elementSize,
qsizetype headerSize )
noexcept
Since
5.7

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.

Note
The memory block may contain up to elementSize - 1 bytes more than needed.

Definition at line 86 of file qarraydata.cpp.