Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 using ReallocFn = void*(const AllocatorDispatch* self, | 55 using ReallocFn = void*(const AllocatorDispatch* self, |
| 56 void* address, | 56 void* address, |
| 57 size_t size); | 57 size_t size); |
| 58 using FreeFn = void(const AllocatorDispatch* self, void* address); | 58 using FreeFn = void(const AllocatorDispatch* self, void* address); |
| 59 // Returns the best available estimate for the actual amount of memory | 59 // Returns the best available estimate for the actual amount of memory |
| 60 // consumed by the allocation |address|. If possible, this should include | 60 // consumed by the allocation |address|. If possible, this should include |
| 61 // heap overhead or at least a decent estimate of the full cost of the | 61 // heap overhead or at least a decent estimate of the full cost of the |
| 62 // allocation. If no good estimate is possible, returns zero. | 62 // allocation. If no good estimate is possible, returns zero. |
| 63 using GetSizeEstimateFn = size_t(const AllocatorDispatch* self, | 63 using GetSizeEstimateFn = size_t(const AllocatorDispatch* self, |
| 64 void* address); | 64 void* address); |
| 65 using BatchMallocFn = unsigned(const AllocatorDispatch* self, | |
|
DmitrySkiba
2017/01/10 21:48:34
We should also add a callback for free_definite_si
| |
| 66 size_t size, | |
| 67 void** results, | |
| 68 unsigned num_requested); | |
| 69 using BatchFreeFn = void(const AllocatorDispatch* self, | |
| 70 void** to_be_freed, | |
| 71 unsigned num_to_be_freed); | |
| 65 | 72 |
| 66 AllocFn* const alloc_function; | 73 AllocFn* const alloc_function; |
| 67 AllocZeroInitializedFn* const alloc_zero_initialized_function; | 74 AllocZeroInitializedFn* const alloc_zero_initialized_function; |
| 68 AllocAlignedFn* const alloc_aligned_function; | 75 AllocAlignedFn* const alloc_aligned_function; |
| 69 ReallocFn* const realloc_function; | 76 ReallocFn* const realloc_function; |
| 70 FreeFn* const free_function; | 77 FreeFn* const free_function; |
| 71 GetSizeEstimateFn* const get_size_estimate_function; | 78 GetSizeEstimateFn* const get_size_estimate_function; |
| 79 BatchMallocFn* const batch_malloc_function; | |
| 80 BatchFreeFn* const batch_free_function; | |
| 72 | 81 |
| 73 const AllocatorDispatch* next; | 82 const AllocatorDispatch* next; |
| 74 | 83 |
| 75 // |default_dispatch| is statically defined by one (and only one) of the | 84 // |default_dispatch| is statically defined by one (and only one) of the |
| 76 // allocator_shim_default_dispatch_to_*.cc files, depending on the build | 85 // allocator_shim_default_dispatch_to_*.cc files, depending on the build |
| 77 // configuration. | 86 // configuration. |
| 78 static const AllocatorDispatch default_dispatch; | 87 static const AllocatorDispatch default_dispatch; |
| 79 }; | 88 }; |
| 80 | 89 |
| 81 // When true makes malloc behave like new, w.r.t calling the new_handler if | 90 // When true makes malloc behave like new, w.r.t calling the new_handler if |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 94 | 103 |
| 95 // Test-only. Rationale: (1) lack of use cases; (2) dealing safely with a | 104 // Test-only. Rationale: (1) lack of use cases; (2) dealing safely with a |
| 96 // removal of arbitrary elements from a singly linked list would require a lock | 105 // removal of arbitrary elements from a singly linked list would require a lock |
| 97 // in malloc(), which we really don't want. | 106 // in malloc(), which we really don't want. |
| 98 BASE_EXPORT void RemoveAllocatorDispatchForTesting(AllocatorDispatch* dispatch); | 107 BASE_EXPORT void RemoveAllocatorDispatchForTesting(AllocatorDispatch* dispatch); |
| 99 | 108 |
| 100 } // namespace allocator | 109 } // namespace allocator |
| 101 } // namespace base | 110 } // namespace base |
| 102 | 111 |
| 103 #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ | 112 #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ |
| OLD | NEW |