| 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 #include <stddef.h> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 | 12 |
| 14 // malloc_unchecked is required to implement UncheckedMalloc properly. | 13 // malloc_unchecked is required to implement UncheckedMalloc properly. |
| 15 // It's provided by allocator_shim_win.cc but since that's not always present, | 14 // It's provided by allocator_shim_win.cc but since that's not always present, |
| 16 // we provide a default that falls back to regular malloc. | 15 // we provide a default that falls back to regular malloc. |
| 17 typedef void* (*MallocFn)(size_t); | 16 typedef void* (*MallocFn)(size_t); |
| 18 extern "C" void* (*const malloc_unchecked)(size_t); | 17 extern "C" void* (*const malloc_unchecked)(size_t); |
| 19 extern "C" void* (*const malloc_default)(size_t) = &malloc; | 18 extern "C" void* (*const malloc_default)(size_t) = &malloc; |
| 20 | 19 |
| 21 #if defined(_M_IX86) | 20 #if defined(_M_IX86) |
| 22 #pragma comment(linker, "/alternatename:_malloc_unchecked=_malloc_default") | 21 #pragma comment(linker, "/alternatename:_malloc_unchecked=_malloc_default") |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 _set_new_mode(1); | 59 _set_new_mode(1); |
| 61 } | 60 } |
| 62 | 61 |
| 63 // Implemented using a weak symbol. | 62 // Implemented using a weak symbol. |
| 64 bool UncheckedMalloc(size_t size, void** result) { | 63 bool UncheckedMalloc(size_t size, void** result) { |
| 65 *result = malloc_unchecked(size); | 64 *result = malloc_unchecked(size); |
| 66 return *result != NULL; | 65 return *result != NULL; |
| 67 } | 66 } |
| 68 | 67 |
| 69 } // namespace base | 68 } // namespace base |
| OLD | NEW |