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 */ |
}; |