Ensure QTypedArrayData is just a shim over QArrayData
Change-Id: I6f41ca054d0e0a0c4642f0b841b3b3df9559f818 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
parent
7c9e345551
commit
99e7ad660f
@ -140,18 +140,21 @@ struct QTypedArrayData
|
|||||||
static QTypedArrayData *allocate(size_t capacity,
|
static QTypedArrayData *allocate(size_t capacity,
|
||||||
AllocationOptions options = Default) Q_REQUIRED_RESULT
|
AllocationOptions options = Default) Q_REQUIRED_RESULT
|
||||||
{
|
{
|
||||||
|
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||||
return static_cast<QTypedArrayData *>(QArrayData::allocate(sizeof(T),
|
return static_cast<QTypedArrayData *>(QArrayData::allocate(sizeof(T),
|
||||||
Q_ALIGNOF(AlignmentDummy), capacity, options));
|
Q_ALIGNOF(AlignmentDummy), capacity, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deallocate(QArrayData *data)
|
static void deallocate(QArrayData *data)
|
||||||
{
|
{
|
||||||
|
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||||
QArrayData::deallocate(data, sizeof(T), Q_ALIGNOF(AlignmentDummy));
|
QArrayData::deallocate(data, sizeof(T), Q_ALIGNOF(AlignmentDummy));
|
||||||
}
|
}
|
||||||
|
|
||||||
static QTypedArrayData *fromRawData(const T *data, size_t n,
|
static QTypedArrayData *fromRawData(const T *data, size_t n,
|
||||||
AllocationOptions options = Default)
|
AllocationOptions options = Default)
|
||||||
{
|
{
|
||||||
|
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||||
QTypedArrayData *result = allocate(0, options | RawData);
|
QTypedArrayData *result = allocate(0, options | RawData);
|
||||||
if (result) {
|
if (result) {
|
||||||
Q_ASSERT(!result->ref.isShared()); // No shared empty, please!
|
Q_ASSERT(!result->ref.isShared()); // No shared empty, please!
|
||||||
@ -165,6 +168,7 @@ struct QTypedArrayData
|
|||||||
|
|
||||||
static QTypedArrayData *sharedNull()
|
static QTypedArrayData *sharedNull()
|
||||||
{
|
{
|
||||||
|
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||||
return static_cast<QTypedArrayData *>(
|
return static_cast<QTypedArrayData *>(
|
||||||
const_cast<QArrayData *>(&QArrayData::shared_null));
|
const_cast<QArrayData *>(&QArrayData::shared_null));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user