Chromium Code Reviews| Index: base/allocator/allocator_extension.h |
| diff --git a/base/allocator/allocator_extension.h b/base/allocator/allocator_extension.h |
| index 64bfd1cc4acaa3fe2a8fc1e8f80ab1fe674f3856..f19d7b557b16c603da61227dfb69f48d95fa69fd 100644 |
| --- a/base/allocator/allocator_extension.h |
| +++ b/base/allocator/allocator_extension.h |
| @@ -7,12 +7,18 @@ |
| #include <stddef.h> // for size_t |
| +#include <type_traits> // for std::add_pointer |
| + |
| #include "base/base_export.h" |
| #include "build/build_config.h" |
| namespace base { |
| namespace allocator { |
| +// Callback types for alloc and free. |
| +using AllocHookFunc = std::add_pointer<void(const void*, size_t)>::type; |
|
Primiano Tucci (use gerrit)
2016/03/02 22:16:11
I think there is an unresolved comment here, maybe
Simon Que
2016/03/02 22:35:25
Done.
|
| +using FreeHookFunc = std::add_pointer<void(const void*)>::type; |
| + |
| // Request that the allocator release any free memory it knows about to the |
| // system. |
| BASE_EXPORT void ReleaseFreeMemory(); |
| @@ -25,6 +31,25 @@ BASE_EXPORT bool GetNumericProperty(const char* name, size_t* value); |
| BASE_EXPORT bool IsHeapProfilerRunning(); |
| +// Register callbacks for alloc and free. Can only store one callback at a time |
| +// for each of alloc and free. |
| +BASE_EXPORT void SetHooks(AllocHookFunc alloc_hook, FreeHookFunc free_hook); |
| + |
| +// Attempts to unwind the call stack from the current location where this |
| +// function is being called from. Must be called from a hook function registered |
| +// by calling SetSingle{Alloc,Free}Hook, directly or indirectly. |
| +// |
| +// Arguments: |
| +// stack: pointer to a pre-allocated array of void*'s. |
| +// max_stack_size: indicates the size of the array in |stack|. |
| +// skip_count: Indicates how many initial call stack levels to skip before |
| +// storing the caller of alloc/free. This value might not be |
| +// used, depending on the specific implementation. |
| +// |
| +// Returns the number of call stack frames stored in |stack|, or 0 if no call |
| +// stack information is available. |
| +BASE_EXPORT int GetCallStack(void** stack, int max_stack_size, int skip_count); |
|
Primiano Tucci (use gerrit)
2016/03/02 22:16:11
There is another unresolved comment here:
It looks
Simon Que
2016/03/02 22:35:25
Done.
|
| + |
| } // namespace allocator |
| } // namespace base |