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

Side by Side Diff: skia/ext/SkMemory_new_handler.cpp

Issue 2011713003: Roll skia to 8cc209111876b7c78b5ec577c9221d8ed5e21024 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « skia/BUILD.gn ('k') | skia/ext/bitmap_platform_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "base/process/memory.h" 7 #include "base/process/memory.h"
8 8
9 #include "third_party/skia/include/core/SkTypes.h" 9 #include "third_party/skia/include/core/SkTypes.h"
10 10
11 // This implementation of sk_malloc_flags() and friends is similar to 11 // This implementation of sk_malloc_flags() and friends is similar to
12 // SkMemory_malloc.cpp, except it uses base::UncheckedMalloc and friends 12 // SkMemory_malloc.cpp, except it uses base::UncheckedMalloc and friends
13 // for non-SK_MALLOC_THROW calls. 13 // for non-SK_MALLOC_THROW calls.
14 // 14 //
15 // The name of this file is historic: a previous implementation tried to 15 // The name of this file is historic: a previous implementation tried to
16 // use std::set_new_handler() for the same effect, but it didn't actually work. 16 // use std::set_new_handler() for the same effect, but it didn't actually work.
17 17
18 static inline void* throw_on_failure(size_t size, void* p) { 18 static inline void* throw_on_failure(size_t size, void* p) {
19 if (size > 0 && p == NULL) { 19 if (size > 0 && p == NULL) {
20 // 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.
21 sk_out_of_memory(); 21 sk_out_of_memory();
22 } 22 }
23 return p; 23 return p;
24 } 24 }
25 25
26 void sk_throw() { 26 void sk_abort_no_print() {
27 SkASSERT(!"sk_throw"); 27 abort();
28 abort();
29 } 28 }
30 29
31 void sk_out_of_memory(void) { 30 void sk_out_of_memory(void) {
32 SkASSERT(!"sk_out_of_memory"); 31 SkASSERT(!"sk_out_of_memory");
33 abort(); 32 abort();
34 } 33 }
35 34
36 void* sk_realloc_throw(void* addr, size_t size) { 35 void* sk_realloc_throw(void* addr, size_t size) {
37 return throw_on_failure(size, realloc(addr, size)); 36 return throw_on_failure(size, realloc(addr, size));
38 } 37 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 result = calloc(1, size); 92 result = calloc(1, size);
94 #else 93 #else
95 // It's the responsibility of the caller to check the return value. 94 // It's the responsibility of the caller to check the return value.
96 ignore_result(base::UncheckedCalloc(size, 1, &result)); 95 ignore_result(base::UncheckedCalloc(size, 1, &result));
97 #endif 96 #endif
98 if (result) { 97 if (result) {
99 prevent_overcommit(0, size, result); 98 prevent_overcommit(0, size, result);
100 } 99 }
101 return result; 100 return result;
102 } 101 }
OLDNEW
« no previous file with comments | « skia/BUILD.gn ('k') | skia/ext/bitmap_platform_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698