From 329ec3a268d636cc2cd4e403b5323c4d65723d33 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 6 Aug 2015 13:03:29 -0700 Subject: [PATCH] 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 --- src/corelib/tools/qarraydata.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 94182a531c..a2d9901677 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -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;