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

Side by Side 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: mtkein suggestions. 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 unified diff | Download patch
« include/core/SkTypes.h ('K') | « include/core/SkTypes.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« include/core/SkTypes.h ('K') | « include/core/SkTypes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698