| 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" | |
| 11 #include "base/allocator/malloc_zone_functions_mac.h" | 10 #include "base/allocator/malloc_zone_functions_mac.h" |
| 12 #include "third_party/apple_apsl/malloc.h" | 11 #include "third_party/apple_apsl/malloc.h" |
| 13 | 12 |
| 14 namespace base { | 13 namespace base { |
| 15 namespace allocator { | 14 namespace allocator { |
| 16 | 15 |
| 17 void OverrideMacSymbols() { | 16 MallocZoneFunctions MallocZoneFunctionsToReplaceDefault() { |
| 18 MallocZoneFunctions new_functions; | 17 MallocZoneFunctions new_functions; |
| 18 memset(&new_functions, 0, sizeof(MallocZoneFunctions)); |
| 19 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 { |
| 20 return ShimGetSizeEstimate(ptr, zone); | 20 return ShimGetSizeEstimate(ptr, zone); |
| 21 }; | 21 }; |
| 22 new_functions.malloc = [](malloc_zone_t* zone, size_t size) -> void* { | 22 new_functions.malloc = [](malloc_zone_t* zone, size_t size) -> void* { |
| 23 return ShimMalloc(size, zone); | 23 return ShimMalloc(size, zone); |
| 24 }; | 24 }; |
| 25 new_functions.calloc = [](malloc_zone_t* zone, size_t n, | 25 new_functions.calloc = [](malloc_zone_t* zone, size_t n, |
| 26 size_t size) -> void* { | 26 size_t size) -> void* { |
| 27 return ShimCalloc(n, size, zone); | 27 return ShimCalloc(n, size, zone); |
| 28 }; | 28 }; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 46 ShimBatchFree(to_be_freed, num_to_be_freed, zone); | 46 ShimBatchFree(to_be_freed, num_to_be_freed, zone); |
| 47 }; | 47 }; |
| 48 new_functions.memalign = [](malloc_zone_t* zone, size_t alignment, | 48 new_functions.memalign = [](malloc_zone_t* zone, size_t alignment, |
| 49 size_t size) -> void* { | 49 size_t size) -> void* { |
| 50 return ShimMemalign(alignment, size, zone); | 50 return ShimMemalign(alignment, size, zone); |
| 51 }; | 51 }; |
| 52 new_functions.free_definite_size = [](malloc_zone_t* zone, void* ptr, | 52 new_functions.free_definite_size = [](malloc_zone_t* zone, void* ptr, |
| 53 size_t size) { | 53 size_t size) { |
| 54 ShimFreeDefiniteSize(ptr, size, zone); | 54 ShimFreeDefiniteSize(ptr, size, zone); |
| 55 }; | 55 }; |
| 56 | 56 return new_functions; |
| 57 base::allocator::ReplaceFunctionsForStoredZones(&new_functions); | |
| 58 } | 57 } |
| 59 | 58 |
| 60 } // namespace allocator | 59 } // namespace allocator |
| 61 } // namespace base | 60 } // namespace base |
| OLD | NEW |