| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifdef BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_MAC_SYMBOLS_H_ | 5 #ifdef BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_MAC_SYMBOLS_H_ |
| 6 #error This header is meant to be included only once by allocator_shim.cc | 6 #error This header is meant to be included only once by allocator_shim.cc |
| 7 #endif | 7 #endif |
| 8 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_MAC_SYMBOLS_H_ | 8 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_MAC_SYMBOLS_H_ |
| 9 | 9 |
| 10 #include "base/allocator/allocator_interception_mac.h" | 10 #include "base/allocator/allocator_interception_mac.h" |
| 11 #include "base/allocator/malloc_zone_functions_mac.h" |
| 11 #include "third_party/apple_apsl/malloc.h" | 12 #include "third_party/apple_apsl/malloc.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 namespace allocator { | 15 namespace allocator { |
| 15 | 16 |
| 16 void OverrideMacSymbols() { | 17 void OverrideMacSymbols() { |
| 17 MallocZoneFunctions new_functions; | 18 MallocZoneFunctions new_functions; |
| 18 new_functions.size = [](malloc_zone_t* zone, const void* ptr) -> size_t { | 19 new_functions.size = [](malloc_zone_t* zone, const void* ptr) -> size_t { |
| 19 return ShimGetSizeEstimate(ptr, zone); | 20 return ShimGetSizeEstimate(ptr, zone); |
| 20 }; | 21 }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 46 }; | 47 }; |
| 47 new_functions.memalign = [](malloc_zone_t* zone, size_t alignment, | 48 new_functions.memalign = [](malloc_zone_t* zone, size_t alignment, |
| 48 size_t size) -> void* { | 49 size_t size) -> void* { |
| 49 return ShimMemalign(alignment, size, zone); | 50 return ShimMemalign(alignment, size, zone); |
| 50 }; | 51 }; |
| 51 new_functions.free_definite_size = [](malloc_zone_t* zone, void* ptr, | 52 new_functions.free_definite_size = [](malloc_zone_t* zone, void* ptr, |
| 52 size_t size) { | 53 size_t size) { |
| 53 ShimFreeDefiniteSize(ptr, size, zone); | 54 ShimFreeDefiniteSize(ptr, size, zone); |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 base::allocator::ReplaceFunctionsForDefaultZone(&new_functions); | 57 base::allocator::ReplaceFunctionsForStoredZones(&new_functions); |
| 57 } | 58 } |
| 58 | 59 |
| 59 } // namespace allocator | 60 } // namespace allocator |
| 60 } // namespace base | 61 } // namespace base |
| OLD | NEW |