From bf0b4f332a2f1ec9860c610d98cd27e483869bec Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 4 Jun 2012 21:06:49 +0200 Subject: Rename QArrayData::AllocateOptions enum and update some flags Rename to QArrayData::ArrayOptions in preparation for these flags being in the array itself, instead of used just for allocating new ones. For that reason, rename QArrayData::Default to DefaultAllocationFlags. And introduce QArray::DefaultRawFlags to mean the flags needed for creating a raw (static) QArrayData. Also rename QArrayData::Grow to GrowsForward, so we may add GrowsBackward in the future. Change-Id: I536d9b34124f775d53cf810f62d6b0eaada8daef Reviewed-by: Simon Hausmann --- src/corelib/tools/qarraydata.h | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/corelib/tools/qarraydata.h') diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index a91dd54262..c2da2767c3 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -76,15 +77,16 @@ struct Q_CORE_EXPORT QArrayData return alloc != 0; } - enum AllocationOption { + enum ArrayOption { CapacityReserved = 0x1, RawData = 0x4, - Grow = 0x8, + GrowsForward = 0x8, - Default = 0 + DefaultAllocationFlags = 0, + DefaultRawFlags = 0 }; - Q_DECLARE_FLAGS(AllocationOptions, AllocationOption) + Q_DECLARE_FLAGS(ArrayOptions, ArrayOption) size_t detachCapacity(size_t newSize) const { @@ -93,17 +95,17 @@ struct Q_CORE_EXPORT QArrayData return newSize; } - AllocationOptions detachFlags() const + ArrayOptions detachFlags() const { - AllocationOptions result; + ArrayOptions result; if (capacityReserved) result |= CapacityReserved; return result; } - AllocationOptions cloneFlags() const + ArrayOptions cloneFlags() const { - AllocationOptions result; + ArrayOptions result; if (capacityReserved) result |= CapacityReserved; return result; @@ -114,9 +116,9 @@ struct Q_CORE_EXPORT QArrayData __attribute__((__malloc__)) #endif static QArrayData *allocate(size_t objectSize, size_t alignment, - size_t capacity, AllocationOptions options = Default) noexcept; + size_t capacity, ArrayOptions options = DefaultAllocationFlags) noexcept; Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, - size_t newCapacity, AllocationOptions newOptions = Default) noexcept; + size_t newCapacity, ArrayOptions newOptions = DefaultAllocationFlags) noexcept; static void deallocate(QArrayData *data, size_t objectSize, size_t alignment) noexcept; @@ -130,7 +132,7 @@ struct Q_CORE_EXPORT QArrayData } }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QArrayData::AllocationOptions) +Q_DECLARE_OPERATORS_FOR_FLAGS(QArrayData::ArrayOptions) template struct QTypedArrayData @@ -225,7 +227,7 @@ struct QTypedArrayData class AlignmentDummy { QArrayData header; T data; }; Q_REQUIRED_RESULT static QTypedArrayData *allocate(size_t capacity, - AllocationOptions options = Default) + ArrayOptions options = DefaultAllocationFlags) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); void *result = QArrayData::allocate(sizeof(T), @@ -237,10 +239,10 @@ struct QTypedArrayData } static QTypedArrayData *reallocateUnaligned(QTypedArrayData *data, size_t capacity, - AllocationOptions options = Default) + ArrayOptions options = DefaultAllocationFlags) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); - void *result = QArrayData::reallocateUnaligned(data, sizeof(T), capacity, options)); + void *result = QArrayData::reallocateUnaligned(data, sizeof(T), capacity, options); #if (defined(Q_CC_GNU) && Q_CC_GNU >= 407) || QT_HAS_BUILTIN(__builtin_assume_aligned) result =__builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy)); #endif @@ -254,7 +256,7 @@ struct QTypedArrayData } static QTypedArrayData *fromRawData(const T *data, size_t n, - AllocationOptions options = Default) + ArrayOptions options = DefaultRawFlags) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); QTypedArrayData *result = allocate(0, options | RawData); -- cgit v1.2.3