| 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 #ifndef BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ | 5 #ifndef BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ |
| 6 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ | 6 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 unsigned num_requested, | 77 unsigned num_requested, |
| 78 void* context); | 78 void* context); |
| 79 using BatchFreeFn = void(const AllocatorDispatch* self, | 79 using BatchFreeFn = void(const AllocatorDispatch* self, |
| 80 void** to_be_freed, | 80 void** to_be_freed, |
| 81 unsigned num_to_be_freed, | 81 unsigned num_to_be_freed, |
| 82 void* context); | 82 void* context); |
| 83 using FreeDefiniteSizeFn = void(const AllocatorDispatch* self, | 83 using FreeDefiniteSizeFn = void(const AllocatorDispatch* self, |
| 84 void* ptr, | 84 void* ptr, |
| 85 size_t size, | 85 size_t size, |
| 86 void* context); | 86 void* context); |
| 87 using TaggedAllocFn = void*(const AllocatorDispatch* self, |
| 88 size_t size, |
| 89 const char* tag); |
| 87 | 90 |
| 88 AllocFn* const alloc_function; | 91 AllocFn* const alloc_function; |
| 89 AllocZeroInitializedFn* const alloc_zero_initialized_function; | 92 AllocZeroInitializedFn* const alloc_zero_initialized_function; |
| 90 AllocAlignedFn* const alloc_aligned_function; | 93 AllocAlignedFn* const alloc_aligned_function; |
| 91 ReallocFn* const realloc_function; | 94 ReallocFn* const realloc_function; |
| 92 FreeFn* const free_function; | 95 FreeFn* const free_function; |
| 93 GetSizeEstimateFn* const get_size_estimate_function; | 96 GetSizeEstimateFn* const get_size_estimate_function; |
| 94 BatchMallocFn* const batch_malloc_function; | 97 BatchMallocFn* const batch_malloc_function; |
| 95 BatchFreeFn* const batch_free_function; | 98 BatchFreeFn* const batch_free_function; |
| 96 FreeDefiniteSizeFn* const free_definite_size_function; | 99 FreeDefiniteSizeFn* const free_definite_size_function; |
| 100 TaggedAllocFn* const tagged_alloc_function; |
| 97 | 101 |
| 98 const AllocatorDispatch* next; | 102 const AllocatorDispatch* next; |
| 99 | 103 |
| 100 // |default_dispatch| is statically defined by one (and only one) of the | 104 // |default_dispatch| is statically defined by one (and only one) of the |
| 101 // allocator_shim_default_dispatch_to_*.cc files, depending on the build | 105 // allocator_shim_default_dispatch_to_*.cc files, depending on the build |
| 102 // configuration. | 106 // configuration. |
| 103 static const AllocatorDispatch default_dispatch; | 107 static const AllocatorDispatch default_dispatch; |
| 104 }; | 108 }; |
| 105 | 109 |
| 106 // When true makes malloc behave like new, w.r.t calling the new_handler if | 110 // When true makes malloc behave like new, w.r.t calling the new_handler if |
| (...skipping 17 matching lines...) Expand all Loading... |
| 124 | 128 |
| 125 #if defined(OS_MACOSX) | 129 #if defined(OS_MACOSX) |
| 126 // On macOS, the allocator shim needs to be turned on during runtime. | 130 // On macOS, the allocator shim needs to be turned on during runtime. |
| 127 BASE_EXPORT void InitializeAllocatorShim(); | 131 BASE_EXPORT void InitializeAllocatorShim(); |
| 128 #endif // defined(OS_MACOSX) | 132 #endif // defined(OS_MACOSX) |
| 129 | 133 |
| 130 } // namespace allocator | 134 } // namespace allocator |
| 131 } // namespace base | 135 } // namespace base |
| 132 | 136 |
| 133 #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ | 137 #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ |
| OLD | NEW |