| 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 // This is a simple allocator based on the windows heap. | 5 // This is a simple allocator based on the windows heap. |
| 6 | 6 |
| 7 #include "base/process/memory.h" |
| 8 |
| 7 extern "C" { | 9 extern "C" { |
| 8 | 10 |
| 9 HANDLE win_heap; | 11 HANDLE win_heap; |
| 10 | 12 |
| 11 bool win_heap_init(bool use_lfh) { | 13 bool win_heap_init(bool use_lfh) { |
| 12 win_heap = HeapCreate(0, 0, 0); | 14 win_heap = HeapCreate(0, 0, 0); |
| 13 if (win_heap == NULL) | 15 if (win_heap == NULL) |
| 14 return false; | 16 return false; |
| 15 | 17 |
| 16 if (use_lfh) { | 18 if (use_lfh) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 reinterpret_cast<void**>(aligned_ptr)[-1] = ptr; | 71 reinterpret_cast<void**>(aligned_ptr)[-1] = ptr; |
| 70 return aligned_ptr; | 72 return aligned_ptr; |
| 71 } | 73 } |
| 72 | 74 |
| 73 void win_heap_memalign_free(void* ptr) { | 75 void win_heap_memalign_free(void* ptr) { |
| 74 if (ptr) | 76 if (ptr) |
| 75 win_heap_free(static_cast<void**>(ptr)[-1]); | 77 win_heap_free(static_cast<void**>(ptr)[-1]); |
| 76 } | 78 } |
| 77 | 79 |
| 78 } // extern "C" | 80 } // extern "C" |
| 81 |
| 82 #if !defined(WIN_USE_ALLOCATOR_SHIM) |
| 83 |
| 84 namespace base { |
| 85 bool UncheckedMalloc(size_t size, void** result) { |
| 86 *result = win_heap_malloc(size); |
| 87 return *result; |
| 88 } |
| 89 } |
| 90 |
| 91 #endif |
| OLD | NEW |