sk_malloc_throw/sk_calloc_throw in debug prints size in failure message
R=caryclark@google.com, mtklein@google.com, reed@google.com Author: halcanary@google.com Review URL: https://codereview.chromium.org/377113004
This commit is contained in:
parent
15840a2e84
commit
61b1436c22
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user