From 4bf8e82d413815cd8ef076e7a5c65d0651a0e27a Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Mon, 13 Jul 2020 12:26:36 +0300 Subject: 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 --- src/corelib/tools/qarraydata.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/corelib/tools/qarraydata.cpp') diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index f46204106d2..cea41dbaff4 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::dataStart(header, alignment); header->alloc = qsizetype(capacity); } *dptr = header; - return reinterpret_cast(data); + return data; } QPair -- cgit v1.2.3