Qt 4.8
Static Public Functions | Public Variables | Static Public Variables | List of all members
QVectorData Struct Reference

#include <qvector.h>

Inheritance diagram for QVectorData:
QVectorTypedData< T >

Static Public Functions

static QVectorDataallocate (int size, int alignment)
 
static void free (QVectorData *data, int alignment)
 
static int grow (int sizeofTypedData, int size, int sizeofT, bool excessive)
 
static QVectorDatamalloc (int sizeofTypedData, int size, int sizeofT, QVectorData *init)
 
static QVectorDatareallocate (QVectorData *old, int newsize, int oldsize, int alignment)
 

Public Variables

int alloc
 
uint capacity: 1
 
QBasicAtomicInt ref
 
uint reserved: 30
 
uint sharable: 1
 
int size
 

Static Public Variables

static QVectorData shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false, 0 }
 

Detailed Description

Definition at line 66 of file qvector.h.

Functions

◆ allocate()

QVectorData * QVectorData::allocate ( int  size,
int  alignment 
)
static

Definition at line 65 of file qvector.cpp.

Referenced by QVector< QPoint >::malloc().

66 {
67  return static_cast<QVectorData *>(alignment > alignmentThreshold() ? qMallocAligned(size, alignment) : qMalloc(size));
68 }
Q_CORE_EXPORT void * qMallocAligned(size_t size, size_t alignment)
Definition: qmalloc.cpp:68
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
static int alignmentThreshold()
Definition: qvector.cpp:48
int size
Definition: qvector.h:70

◆ free()

void QVectorData::free ( QVectorData data,
int  alignment 
)
static

Definition at line 77 of file qvector.cpp.

Referenced by QVectorTypedData< T >::free().

78 {
79  if (alignment > alignmentThreshold())
80  qFreeAligned(x);
81  else
82  qFree(x);
83 }
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
static int alignmentThreshold()
Definition: qvector.cpp:48
Q_CORE_EXPORT void qFreeAligned(void *ptr)
Definition: qmalloc.cpp:118

◆ grow()

int QVectorData::grow ( int  sizeofTypedData,
int  size,
int  sizeofT,
bool  excessive 
)
static

Definition at line 85 of file qvector.cpp.

Referenced by QVector< QPoint >::append(), QVector< QPoint >::insert(), and QVector< QPoint >::resize().

86 {
87  if (excessive)
88  return size + size / 2;
89  return qAllocMore(size * sizeofT, sizeofTypedData - sizeofT) / sizeofT;
90 }
int qAllocMore(int alloc, int extra)
Definition: qbytearray.cpp:70
int size
Definition: qvector.h:70

◆ malloc()

QVectorData * QVectorData::malloc ( int  sizeofTypedData,
int  size,
int  sizeofT,
QVectorData init 
)
static

Definition at line 57 of file qvector.cpp.

Referenced by QVector< QPoint >::QVector(), and QVector< QPoint >::realloc().

58 {
59  QVectorData* p = (QVectorData *)qMalloc(sizeofTypedData + (size - 1) * sizeofT);
60  Q_CHECK_PTR(p);
61  ::memcpy(p, init, sizeofTypedData + (qMin(size, init->alloc) - 1) * sizeofT);
62  return p;
63 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int alloc
Definition: qvector.h:69
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
int size
Definition: qvector.h:70
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853

◆ reallocate()

QVectorData * QVectorData::reallocate ( QVectorData old,
int  newsize,
int  oldsize,
int  alignment 
)
static

Definition at line 70 of file qvector.cpp.

Referenced by QVector< QPoint >::realloc().

71 {
72  if (alignment > alignmentThreshold())
73  return static_cast<QVectorData *>(qReallocAligned(x, newsize, oldsize, alignment));
74  return static_cast<QVectorData *>(qRealloc(x, newsize));
75 }
Q_CORE_EXPORT void * qRealloc(void *ptr, size_t size)
Definition: qmalloc.cpp:63
Q_CORE_EXPORT void * qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment)
Definition: qmalloc.cpp:73
static int alignmentThreshold()
Definition: qvector.cpp:48

Properties

◆ alloc

int QVectorData::alloc

Definition at line 69 of file qvector.h.

Referenced by malloc().

◆ capacity

uint QVectorData::capacity

Definition at line 78 of file qvector.h.

◆ ref

QBasicAtomicInt QVectorData::ref

Definition at line 68 of file qvector.h.

Referenced by QVector< QPoint >::operator=().

◆ reserved

uint QVectorData::reserved

Definition at line 79 of file qvector.h.

◆ sharable

uint QVectorData::sharable

Definition at line 77 of file qvector.h.

Referenced by QVector< QPoint >::setSharable().

◆ shared_null

QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false, 0 }
static

Definition at line 82 of file qvector.h.

Referenced by alignmentThreshold().

◆ size

int QVectorData::size

The documentation for this struct was generated from the following files: