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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 using AllocZeroInitializedFn = void*(const AllocatorDispatch* self, | 49 using AllocZeroInitializedFn = void*(const AllocatorDispatch* self, |
50 size_t n, | 50 size_t n, |
51 size_t size); | 51 size_t size); |
52 using AllocAlignedFn = void*(const AllocatorDispatch* self, | 52 using AllocAlignedFn = void*(const AllocatorDispatch* self, |
53 size_t alignment, | 53 size_t alignment, |
54 size_t size); | 54 size_t size); |
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 | |
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 | |
62 // allocation. | |
63 using GetSizeEstimateFn = size_t(const AllocatorDispatch* self, | |
Primiano Tucci (use gerrit)
2016/08/24 14:11:46
I don't think that this function should be part of
Primiano Tucci (use gerrit)
2016/08/24 15:28:46
siggi@ and I had a chat offline. siggi@ explained
Sigurður Ásgeirsson
2016/09/01 15:18:17
Yeah - it would be nice to fully abstract the noti
Sigurður Ásgeirsson
2016/09/01 15:18:17
Acknowledged.
| |
64 void* address); | |
59 | 65 |
60 AllocFn* const alloc_function; | 66 AllocFn* const alloc_function; |
61 AllocZeroInitializedFn* const alloc_zero_initialized_function; | 67 AllocZeroInitializedFn* const alloc_zero_initialized_function; |
62 AllocAlignedFn* const alloc_aligned_function; | 68 AllocAlignedFn* const alloc_aligned_function; |
63 ReallocFn* const realloc_function; | 69 ReallocFn* const realloc_function; |
64 FreeFn* const free_function; | 70 FreeFn* const free_function; |
71 GetSizeEstimateFn* const get_size_estimate_function; | |
65 | 72 |
66 const AllocatorDispatch* next; | 73 const AllocatorDispatch* next; |
67 | 74 |
68 // |default_dispatch| is statically defined by one (and only one) of the | 75 // |default_dispatch| is statically defined by one (and only one) of the |
69 // allocator_shim_default_dispatch_to_*.cc files, depending on the build | 76 // allocator_shim_default_dispatch_to_*.cc files, depending on the build |
70 // configuration. | 77 // configuration. |
71 static const AllocatorDispatch default_dispatch; | 78 static const AllocatorDispatch default_dispatch; |
72 }; | 79 }; |
73 | 80 |
74 // When true makes malloc behave like new, w.r.t calling the new_handler if | 81 // When true makes malloc behave like new, w.r.t calling the new_handler if |
(...skipping 12 matching lines...) Expand all Loading... | |
87 | 94 |
88 // Test-only. Rationale: (1) lack of use cases; (2) dealing safely with a | 95 // Test-only. Rationale: (1) lack of use cases; (2) dealing safely with a |
89 // removal of arbitrary elements from a singly linked list would require a lock | 96 // removal of arbitrary elements from a singly linked list would require a lock |
90 // in malloc(), which we really don't want. | 97 // in malloc(), which we really don't want. |
91 BASE_EXPORT void RemoveAllocatorDispatchForTesting(AllocatorDispatch* dispatch); | 98 BASE_EXPORT void RemoveAllocatorDispatchForTesting(AllocatorDispatch* dispatch); |
92 | 99 |
93 } // namespace allocator | 100 } // namespace allocator |
94 } // namespace base | 101 } // namespace base |
95 | 102 |
96 #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ | 103 #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ |
OLD | NEW |