Chromium Code Reviews| 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; |
| } |