summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qarraydata.cpp
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2020-07-13 12:26:36 +0300
committerAndrei Golubev <andrei.golubev@qt.io>2020-08-18 12:55:38 +0200
commit4bf8e82d413815cd8ef076e7a5c65d0651a0e27a (patch)
tree184ab55f4a166fe64e1a7002b9601c18dc9f09de /src/corelib/tools/qarraydata.cpp
parent0bd647fa4ffb3319bf3b1d044441b137910629e1 (diff)
Add QArrayDataPointer::freeSpace*() functions
Added functions that tell how much free space is available at the beginning and at the end of the storage Updated preconditions of operations to use freeSpace* functions Also, changed casts uint(this->size) to size_t(this->size) Task-number: QTBUG-84320 Change-Id: Iad94c1060a00f62068da9d1327e332a00d4f4109 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/corelib/tools/qarraydata.cpp')
-rw-r--r--src/corelib/tools/qarraydata.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp
index f46204106d..cea41dbaff 100644
--- a/src/corelib/tools/qarraydata.cpp
+++ b/src/corelib/tools/qarraydata.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -191,16 +191,15 @@ void *QArrayData::allocate(QArrayData **dptr, qsizetype objectSize, qsizetype al
qsizetype allocSize = calculateBlockSize(capacity, objectSize, headerSize, options);
QArrayData *header = allocateData(allocSize, options);
- quintptr data = 0;
+ void *data = nullptr;
if (header) {
// find where offset should point to so that data() is aligned to alignment bytes
- data = (quintptr(header) + sizeof(QArrayData) + alignment - 1)
- & ~(alignment - 1);
+ data = QTypedArrayData<void>::dataStart(header, alignment);
header->alloc = qsizetype(capacity);
}
*dptr = header;
- return reinterpret_cast<void *>(data);
+ return data;
}
QPair<QArrayData *, void *>