| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/allocator/allocator_shim.h" | 5 #include "base/allocator/allocator_shim.h" |
| 6 | 6 |
| 7 #include "base/allocator/winheap_stubs_win.h" | 7 #include "base/allocator/winheap_stubs_win.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 void* result = DefaultWinHeapMallocImpl(self, size); | 26 void* result = DefaultWinHeapMallocImpl(self, size); |
| 27 if (result) { | 27 if (result) { |
| 28 memset(result, 0, size); | 28 memset(result, 0, size); |
| 29 } | 29 } |
| 30 return result; | 30 return result; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void* DefaultWinHeapMemalignImpl(const AllocatorDispatch* self, | 33 void* DefaultWinHeapMemalignImpl(const AllocatorDispatch* self, |
| 34 size_t alignment, | 34 size_t alignment, |
| 35 size_t size) { | 35 size_t size) { |
| 36 CHECK(false) << "The windows heap does not support memalign."; | 36 // The windows heap does not support memalign. |
| 37 CHECK(false); |
| 37 return nullptr; | 38 return nullptr; |
| 38 } | 39 } |
| 39 | 40 |
| 40 void* DefaultWinHeapReallocImpl(const AllocatorDispatch* self, | 41 void* DefaultWinHeapReallocImpl(const AllocatorDispatch* self, |
| 41 void* address, | 42 void* address, |
| 42 size_t size) { | 43 size_t size) { |
| 43 return base::allocator::WinHeapRealloc(address, size); | 44 return base::allocator::WinHeapRealloc(address, size); |
| 44 } | 45 } |
| 45 | 46 |
| 46 void DefaultWinHeapFreeImpl(const AllocatorDispatch*, void* address) { | 47 void DefaultWinHeapFreeImpl(const AllocatorDispatch*, void* address) { |
| 47 base::allocator::WinHeapFree(address); | 48 base::allocator::WinHeapFree(address); |
| 48 } | 49 } |
| 49 | 50 |
| 50 size_t DefaultWinHeapGetSizeEstimateImpl(const AllocatorDispatch*, | 51 size_t DefaultWinHeapGetSizeEstimateImpl(const AllocatorDispatch*, |
| 51 void* address) { | 52 void* address) { |
| 52 return base::allocator::WinHeapGetSizeEstimate(address); | 53 return base::allocator::WinHeapGetSizeEstimate(address); |
| 53 } | 54 } |
| 54 | 55 |
| 55 } // namespace | 56 } // namespace |
| 56 | 57 |
| 57 const AllocatorDispatch AllocatorDispatch::default_dispatch = { | 58 const AllocatorDispatch AllocatorDispatch::default_dispatch = { |
| 58 &DefaultWinHeapMallocImpl, | 59 &DefaultWinHeapMallocImpl, |
| 59 &DefaultWinHeapCallocImpl, | 60 &DefaultWinHeapCallocImpl, |
| 60 &DefaultWinHeapMemalignImpl, | 61 &DefaultWinHeapMemalignImpl, |
| 61 &DefaultWinHeapReallocImpl, | 62 &DefaultWinHeapReallocImpl, |
| 62 &DefaultWinHeapFreeImpl, | 63 &DefaultWinHeapFreeImpl, |
| 63 &DefaultWinHeapGetSizeEstimateImpl, | 64 &DefaultWinHeapGetSizeEstimateImpl, |
| 64 nullptr, /* next */ | 65 nullptr, /* next */ |
| 65 }; | 66 }; |
| OLD | NEW |