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

Side by Side Diff: src/ports/SkMemory_malloc.cpp

Issue 26298002: style nit for myself retroactively: throwOnFailure -> throw_on_failure (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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* throwOnFailure(size_t size, void* p) { 12 static inline void* throw_on_failure(size_t size, void* p) {
13 if (size > 0 && p == NULL) { 13 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. 14 // 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(); 15 sk_out_of_memory();
16 } 16 }
17 return p; 17 return p;
18 } 18 }
19 19
20 void sk_throw() { 20 void sk_throw() {
21 SkDEBUGFAIL("sk_throw"); 21 SkDEBUGFAIL("sk_throw");
22 abort(); 22 abort();
23 } 23 }
24 24
25 void sk_out_of_memory(void) { 25 void sk_out_of_memory(void) {
26 SkDEBUGFAIL("sk_out_of_memory"); 26 SkDEBUGFAIL("sk_out_of_memory");
27 abort(); 27 abort();
28 } 28 }
29 29
30 void* sk_malloc_throw(size_t size) { 30 void* sk_malloc_throw(size_t size) {
31 return sk_malloc_flags(size, SK_MALLOC_THROW); 31 return sk_malloc_flags(size, SK_MALLOC_THROW);
32 } 32 }
33 33
34 void* sk_realloc_throw(void* addr, size_t size) { 34 void* sk_realloc_throw(void* addr, size_t size) {
35 return throwOnFailure(size, realloc(addr, size)); 35 return throw_on_failure(size, realloc(addr, size));
36 } 36 }
37 37
38 void sk_free(void* p) { 38 void sk_free(void* p) {
39 if (p) { 39 if (p) {
40 free(p); 40 free(p);
41 } 41 }
42 } 42 }
43 43
44 void* sk_malloc_flags(size_t size, unsigned flags) { 44 void* sk_malloc_flags(size_t size, unsigned flags) {
45 void* p = malloc(size); 45 void* p = malloc(size);
46 if (flags & SK_MALLOC_THROW) { 46 if (flags & SK_MALLOC_THROW) {
47 return throwOnFailure(size, p); 47 return throw_on_failure(size, p);
48 } else { 48 } else {
49 return p; 49 return p;
50 } 50 }
51 } 51 }
52 52
53 void* sk_calloc(size_t size) { 53 void* sk_calloc(size_t size) {
54 return calloc(size, 1); 54 return calloc(size, 1);
55 } 55 }
56 56
57 void* sk_calloc_throw(size_t size) { 57 void* sk_calloc_throw(size_t size) {
58 return throwOnFailure(size, sk_calloc(size)); 58 return throw_on_failure(size, sk_calloc(size));
59 } 59 }
OLDNEW
« 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