summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-08-06 13:03:29 -0700
committerLars Knoll <lars.knoll@qt.io>2019-12-07 14:17:31 +0100
commit329ec3a268d636cc2cd4e403b5323c4d65723d33 (patch)
tree73f5bdc78f08f67c7aac400336cad9a2772a2e06
parentd7e7befe500931afce6dee00bea81ac85b32a69f (diff)
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>
-rw-r--r--src/corelib/tools/qarraydata.h6
1 files changed, 5 insertions, 1 deletions
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;