OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/process/memory.h" | 5 #include "base/process/memory.h" |
6 | 6 |
7 #include <new.h> | 7 #include <new.h> |
8 #include <psapi.h> | 8 #include <psapi.h> |
| 9 #include <stddef.h> |
9 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 | 13 |
13 // malloc_unchecked is required to implement UncheckedMalloc properly. | 14 // malloc_unchecked is required to implement UncheckedMalloc properly. |
14 // It's provided by allocator_shim_win.cc but since that's not always present, | 15 // It's provided by allocator_shim_win.cc but since that's not always present, |
15 // we provide a default that falls back to regular malloc. | 16 // we provide a default that falls back to regular malloc. |
16 typedef void* (*MallocFn)(size_t); | 17 typedef void* (*MallocFn)(size_t); |
17 extern "C" void* (*const malloc_unchecked)(size_t); | 18 extern "C" void* (*const malloc_unchecked)(size_t); |
18 extern "C" void* (*const malloc_default)(size_t) = &malloc; | 19 extern "C" void* (*const malloc_default)(size_t) = &malloc; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 return instance; | 106 return instance; |
106 } | 107 } |
107 | 108 |
108 // Implemented using a weak symbol. | 109 // Implemented using a weak symbol. |
109 bool UncheckedMalloc(size_t size, void** result) { | 110 bool UncheckedMalloc(size_t size, void** result) { |
110 *result = malloc_unchecked(size); | 111 *result = malloc_unchecked(size); |
111 return *result != NULL; | 112 return *result != NULL; |
112 } | 113 } |
113 | 114 |
114 } // namespace base | 115 } // namespace base |
OLD | NEW |