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

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: move out of include/ 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..0b936c9f8cdd3249bd680609b5f630d56c01cfb8 100644
--- a/src/ports/SkMemory_malloc.cpp
+++ b/src/ports/SkMemory_malloc.cpp
@@ -9,10 +9,19 @@
#include <stdio.h>
#include <stdlib.h>
+#define SK_DEBUGFAILF(fmt, ...) \
+ SkASSERT((SkDebugf(fmt"\n", __VA_ARGS__), false))
+
+static inline void sk_out_of_memory(size_t size) {
+ SK_DEBUGFAILF("sk_out_of_memory (asked for " SK_SIZE_T_SPECIFIER " bytes)",
+ size);
+ 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