| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| 11 | 11 |
| 12 static inline void sk_out_of_memory(size_t size) { |
| 13 SK_DEBUGFAILF("sk_out_of_memory (asked for " SK_SIZE_T_SPECIFIER " bytes)", |
| 14 size); |
| 15 abort(); |
| 16 } |
| 17 |
| 12 static inline void* throw_on_failure(size_t size, void* p) { | 18 static inline void* throw_on_failure(size_t size, void* p) { |
| 13 if (size > 0 && p == NULL) { | 19 if (size > 0 && p == NULL) { |
| 14 // If we've got a NULL here, the only reason we should have failed is ru
nning out of RAM. | 20 // If we've got a NULL here, the only reason we should have failed is ru
nning out of RAM. |
| 15 sk_out_of_memory(); | 21 sk_out_of_memory(size); |
| 16 } | 22 } |
| 17 return p; | 23 return p; |
| 18 } | 24 } |
| 19 | 25 |
| 20 void sk_throw() { | 26 void sk_throw() { |
| 21 SkDEBUGFAIL("sk_throw"); | 27 SkDEBUGFAIL("sk_throw"); |
| 22 abort(); | 28 abort(); |
| 23 } | 29 } |
| 24 | 30 |
| 25 void sk_out_of_memory(void) { | 31 void sk_out_of_memory(void) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 50 } | 56 } |
| 51 } | 57 } |
| 52 | 58 |
| 53 void* sk_calloc(size_t size) { | 59 void* sk_calloc(size_t size) { |
| 54 return calloc(size, 1); | 60 return calloc(size, 1); |
| 55 } | 61 } |
| 56 | 62 |
| 57 void* sk_calloc_throw(size_t size) { | 63 void* sk_calloc_throw(size_t size) { |
| 58 return throw_on_failure(size, sk_calloc(size)); | 64 return throw_on_failure(size, sk_calloc(size)); |
| 59 } | 65 } |
| OLD | NEW |