OLD | NEW |
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 <stddef.h> |
5 #include <stdlib.h> | 6 #include <stdlib.h> |
6 | 7 |
7 #include "base/process/memory.h" | 8 #include "base/process/memory.h" |
8 | 9 #include "build/build_config.h" |
9 #include "third_party/skia/include/core/SkTypes.h" | 10 #include "third_party/skia/include/core/SkTypes.h" |
10 | 11 |
11 // This implementation of sk_malloc_flags() and friends is similar to | 12 // This implementation of sk_malloc_flags() and friends is similar to |
12 // SkMemory_malloc.cpp, except it uses base::UncheckedMalloc and friends | 13 // SkMemory_malloc.cpp, except it uses base::UncheckedMalloc and friends |
13 // for non-SK_MALLOC_THROW calls. | 14 // for non-SK_MALLOC_THROW calls. |
14 // | 15 // |
15 // The name of this file is historic: a previous implementation tried to | 16 // 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. | 17 // use std::set_new_handler() for the same effect, but it didn't actually work. |
17 | 18 |
18 static inline void* throw_on_failure(size_t size, void* p) { | 19 static inline void* throw_on_failure(size_t size, void* p) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 result = calloc(1, size); | 94 result = calloc(1, size); |
94 #else | 95 #else |
95 // It's the responsibility of the caller to check the return value. | 96 // It's the responsibility of the caller to check the return value. |
96 ignore_result(base::UncheckedCalloc(size, 1, &result)); | 97 ignore_result(base::UncheckedCalloc(size, 1, &result)); |
97 #endif | 98 #endif |
98 if (result) { | 99 if (result) { |
99 prevent_overcommit(0, size, result); | 100 prevent_overcommit(0, size, result); |
100 } | 101 } |
101 return result; | 102 return result; |
102 } | 103 } |
OLD | NEW |