Log when malloc functions fail.
This shouldn't happen often, and resulting failures can be hard to debug.
From the bionic unit tests now:
W libc : malloc(18446744073709551615) failed: returning null pointer
W libc : calloc(18446744073709551615, 100) failed: returning null pointer
W libc : calloc(1, 18446744073709551615) failed: returning null pointer
W libc : calloc(18446744073709551615, 18446744073709551615) failed: returning null pointer
W libc : calloc(2, 18446744073709551615) failed: returning null pointer
W libc : calloc(18446744073709551615, 2) failed: returning null pointer
W libc : memalign(4096, 18446744073709551615) failed: returning null pointer
W libc : realloc(0x0, 18446744073709551615) failed: returning null pointer
W libc : realloc(0x75d7526070, 18446744073709551615) failed: returning null pointer
W libc : reallocaray(0x0, 9223372036854775812, 2) failed: returning null pointer
W libc : reallocaray(0x0, 2, 9223372036854775812) failed: returning null pointer
Bug: http://b/12821450
Test: ran tests
Change-Id: Ib176814404f4ba1297416dd3e1edd721bf59aeed
diff --git a/libc/bionic/malloc_common.h b/libc/bionic/malloc_common.h
index a2f338a..e3326cf 100644
--- a/libc/bionic/malloc_common.h
+++ b/libc/bionic/malloc_common.h
@@ -71,4 +71,6 @@
async_safe_format_log(ANDROID_LOG_ERROR, "libc", (format), ##__VA_ARGS__ )
#define info_log(format, ...) \
async_safe_format_log(ANDROID_LOG_INFO, "libc", (format), ##__VA_ARGS__ )
+#define warning_log(format, ...) \
+ async_safe_format_log(ANDROID_LOG_WARN, "libc", (format), ##__VA_ARGS__ )
// =============================================================================