Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: base/allocator/allocator_shim_default_dispatch_to_glibc.cc

Issue 2163783003: Implement a ScopedThreadHeapUsage class to allow profiling per-thread heap usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shim-default
Patch Set: Address Nico's comments. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/allocator/allocator_shim_default_dispatch_to_glibc.cc
diff --git a/base/allocator/allocator_shim_default_dispatch_to_glibc.cc b/base/allocator/allocator_shim_default_dispatch_to_glibc.cc
index 02facbad2eb7cff333e4f9ab6a78b5cffeb52632..f3a535973989e234f0a9c325dd93b3f0475bc68e 100644
--- a/base/allocator/allocator_shim_default_dispatch_to_glibc.cc
+++ b/base/allocator/allocator_shim_default_dispatch_to_glibc.cc
@@ -4,6 +4,8 @@
#include "base/allocator/allocator_shim.h"
+#include <malloc.h>
+
// This translation unit defines a default dispatch for the allocator shim which
// routes allocations to libc functions.
// The code here is strongly inspired from tcmalloc's libc_override_glibc.h.
@@ -40,13 +42,20 @@ void GlibcFree(const AllocatorDispatch*, void* address) {
__libc_free(address);
}
+size_t GlibcGetSizeEstimate(const AllocatorDispatch*, void* address) {
+ // TODO(siggi, primiano): malloc_usable_size may need redirection in the
+ // presence of interposing shims that divert allocations.
+ return malloc_usable_size(address);
+}
+
} // namespace
const AllocatorDispatch AllocatorDispatch::default_dispatch = {
- &GlibcMalloc, /* alloc_function */
- &GlibcCalloc, /* alloc_zero_initialized_function */
- &GlibcMemalign, /* alloc_aligned_function */
- &GlibcRealloc, /* realloc_function */
- &GlibcFree, /* free_function */
- nullptr, /* next */
+ &GlibcMalloc, /* alloc_function */
+ &GlibcCalloc, /* alloc_zero_initialized_function */
+ &GlibcMemalign, /* alloc_aligned_function */
+ &GlibcRealloc, /* realloc_function */
+ &GlibcFree, /* free_function */
+ &GlibcGetSizeEstimate, /* get_size_estimate_function */
+ nullptr, /* next */
};
« no previous file with comments | « base/allocator/allocator_shim.h ('k') | base/allocator/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698