Tell the compiler that QArrayData::allocate allocates memory

ICC, GCC and Clang support __attribute__((malloc)) that tells them that
the function returns newly allocated memory which doesn't alias anything
else. Though technically we may return memory that has already been used
(the shared null or such), that should not be a problem.

Change-Id: Id3d5c7bf4d4c45069621ffff13f7f81f8b08ea3d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
bb10
Thiago Macieira 2015-08-06 13:03:29 -07:00 committed by Lars Knoll
parent d7e7befe50
commit 329ec3a268
1 changed files with 5 additions and 1 deletions

View File

@ -109,7 +109,11 @@ struct Q_CORE_EXPORT QArrayData
return result;
}
Q_REQUIRED_RESULT static QArrayData *allocate(size_t objectSize, size_t alignment,
Q_REQUIRED_RESULT
#if defined(Q_CC_GNU)
__attribute__((__malloc__))
#endif
static QArrayData *allocate(size_t objectSize, size_t alignment,
size_t capacity, AllocationOptions options = Default) noexcept;
Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize,
size_t newCapacity, AllocationOptions newOptions = Default) noexcept;