From 99e7ad660f23dce51ccd68438adae7528013d23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 27 Mar 2012 12:49:00 +0200 Subject: [PATCH] Ensure QTypedArrayData is just a shim over QArrayData Change-Id: I6f41ca054d0e0a0c4642f0b841b3b3df9559f818 Reviewed-by: Bradley T. Hughes --- src/corelib/tools/qarraydata.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 351a75aade4..b4cefe67293 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -140,18 +140,21 @@ struct QTypedArrayData static QTypedArrayData *allocate(size_t capacity, AllocationOptions options = Default) Q_REQUIRED_RESULT { + Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); return static_cast(QArrayData::allocate(sizeof(T), Q_ALIGNOF(AlignmentDummy), capacity, options)); } static void deallocate(QArrayData *data) { + Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); QArrayData::deallocate(data, sizeof(T), Q_ALIGNOF(AlignmentDummy)); } static QTypedArrayData *fromRawData(const T *data, size_t n, AllocationOptions options = Default) { + Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); QTypedArrayData *result = allocate(0, options | RawData); if (result) { Q_ASSERT(!result->ref.isShared()); // No shared empty, please! @@ -165,6 +168,7 @@ struct QTypedArrayData static QTypedArrayData *sharedNull() { + Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); return static_cast( const_cast(&QArrayData::shared_null)); }