diff options
Diffstat (limited to 'src/corelib/tools/qarraydata.h')
| -rw-r--r-- | src/corelib/tools/qarraydata.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 0226fa4c925..856a9521ad2 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -235,6 +235,15 @@ struct QTypedArrayData static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); QArrayData::deallocate(data, sizeof(T), alignof(AlignmentDummy)); } + + static T *dataStart(QArrayData *data, qsizetype alignment) noexcept + { + // Alignment is a power of two + Q_ASSERT(alignment >= qsizetype(alignof(QArrayData)) && !(alignment & (alignment - 1))); + void *start = reinterpret_cast<void *>( + (quintptr(data) + sizeof(QArrayData) + alignment - 1) & ~(alignment - 1)); + return static_cast<T *>(start); + } }; namespace QtPrivate { |
