Title: [210840] trunk/Source/WTF
Revision
210840
Author
[email protected]
Date
2017-01-17 17:37:36 -0800 (Tue, 17 Jan 2017)

Log Message

Annotate FastMalloc functions with returns_nonnull attribute.
<https://webkit.org/b/167144>

Reviewed by Antti Koivisto.

Decorate fastMalloc() and friends with __attribute__((returns_nonnull)) for supporting
compilers that can do useful things with that information.

* wtf/Compiler.h:
* wtf/FastMalloc.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (210839 => 210840)


--- trunk/Source/WTF/ChangeLog	2017-01-18 01:35:46 UTC (rev 210839)
+++ trunk/Source/WTF/ChangeLog	2017-01-18 01:37:36 UTC (rev 210840)
@@ -1,3 +1,16 @@
+2017-01-17  Andreas Kling  <[email protected]>
+
+        Annotate FastMalloc functions with returns_nonnull attribute.
+        <https://webkit.org/b/167144>
+
+        Reviewed by Antti Koivisto.
+
+        Decorate fastMalloc() and friends with __attribute__((returns_nonnull)) for supporting
+        compilers that can do useful things with that information.
+
+        * wtf/Compiler.h:
+        * wtf/FastMalloc.h:
+
 2017-01-17  Joseph Pecoraro  <[email protected]>
 
         ENABLE(USER_TIMING) Not Defined for Apple Windows or OS X Ports

Modified: trunk/Source/WTF/wtf/Compiler.h (210839 => 210840)


--- trunk/Source/WTF/wtf/Compiler.h	2017-01-18 01:35:46 UTC (rev 210839)
+++ trunk/Source/WTF/wtf/Compiler.h	2017-01-18 01:37:36 UTC (rev 210840)
@@ -240,6 +240,15 @@
 #define NO_RETURN
 #endif
 
+/* RETURNS_NONNULL */
+#if !defined(RETURNS_NONNULL) && COMPILER(GCC_OR_CLANG)
+#define RETURNS_NONNULL __attribute__((returns_nonnull))
+#endif
+
+#if !defined(RETURNS_NONNULL)
+#define RETURNS_NONNULL
+#endif
+
 /* NO_RETURN_WITH_VALUE */
 
 #if !defined(NO_RETURN_WITH_VALUE) && !COMPILER(MSVC)

Modified: trunk/Source/WTF/wtf/FastMalloc.h (210839 => 210840)


--- trunk/Source/WTF/wtf/FastMalloc.h	2017-01-18 01:35:46 UTC (rev 210839)
+++ trunk/Source/WTF/wtf/FastMalloc.h	2017-01-18 01:37:36 UTC (rev 210840)
@@ -45,11 +45,11 @@
 WTF_EXPORT_PRIVATE bool isFastMallocEnabled();
 
 // These functions call CRASH() if an allocation fails.
-WTF_EXPORT_PRIVATE void* fastMalloc(size_t);
-WTF_EXPORT_PRIVATE void* fastZeroedMalloc(size_t);
-WTF_EXPORT_PRIVATE void* fastCalloc(size_t numElements, size_t elementSize);
-WTF_EXPORT_PRIVATE void* fastRealloc(void*, size_t);
-WTF_EXPORT_PRIVATE char* fastStrDup(const char*);
+WTF_EXPORT_PRIVATE void* fastMalloc(size_t) RETURNS_NONNULL;
+WTF_EXPORT_PRIVATE void* fastZeroedMalloc(size_t) RETURNS_NONNULL;
+WTF_EXPORT_PRIVATE void* fastCalloc(size_t numElements, size_t elementSize) RETURNS_NONNULL;
+WTF_EXPORT_PRIVATE void* fastRealloc(void*, size_t) RETURNS_NONNULL;
+WTF_EXPORT_PRIVATE char* fastStrDup(const char*) RETURNS_NONNULL;
 
 WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastMalloc(size_t);
 TryMallocReturnValue tryFastZeroedMalloc(size_t);
@@ -58,7 +58,7 @@
 WTF_EXPORT_PRIVATE void fastFree(void*);
 
 // Allocations from fastAlignedMalloc() must be freed using fastAlignedFree().
-WTF_EXPORT_PRIVATE void* fastAlignedMalloc(size_t alignment, size_t);
+WTF_EXPORT_PRIVATE void* fastAlignedMalloc(size_t alignment, size_t) RETURNS_NONNULL;
 WTF_EXPORT_PRIVATE void* tryFastAlignedMalloc(size_t alignment, size_t);
 WTF_EXPORT_PRIVATE void fastAlignedFree(void*);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to