Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: src/ports/SkMemory_malloc.cpp

Issue 377113004: sk_malloc_throw/sk_calloc_throw in debug prints size in failure message (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkMemory_malloc.cpp
diff --git a/src/ports/SkMemory_malloc.cpp b/src/ports/SkMemory_malloc.cpp
index 3a5608ef15b40e7514276b5dfc94e8fa8fb7a497..2664b554be983627291e50d4ec72c19da2c16057 100644
--- a/src/ports/SkMemory_malloc.cpp
+++ b/src/ports/SkMemory_malloc.cpp
@@ -9,10 +9,27 @@
#include <stdio.h>
#include <stdlib.h>
+#ifdef SK_DEBUG
+ #define SK_DEBUGFAILF(message, ...) \
mtklein 2014/07/10 15:03:40 Can we put this in SkTypes as #define SK_DEBUGFAI
hal.canary 2014/07/10 15:15:11 Done. Mike Reed: please note that this touches i
+ do { \
+ SkNO_RETURN_HINT(); \
+ SkDebugf("%s:%d: fail:" message "]\n", \
+ __FILE__, __LINE__, __VA_ARGS__); \
+ SK_CRASH(); \
+ } while(0)
+#else
+ #define SK_DEBUGFAILF(message, ...)
+#endif
+
+static inline void sk_out_of_memory(size_t size) {
+ SK_DEBUGFAILF("sk_out_of_memory [0x%lx]", static_cast<unsigned long>(size));
mtklein 2014/07/10 15:03:40 Let's be explicit this is a byte size, and perhaps
hal.canary 2014/07/10 15:15:11 Done.
+ abort();
+}
+
static inline void* throw_on_failure(size_t size, void* p) {
if (size > 0 && p == NULL) {
// If we've got a NULL here, the only reason we should have failed is running out of RAM.
- sk_out_of_memory();
+ sk_out_of_memory(size);
}
return p;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698