diff options
Diffstat (limited to 'base/allocator/allocator_shim_default_dispatch_to_glibc.cc')
-rw-r--r-- | base/allocator/allocator_shim_default_dispatch_to_glibc.cc | 53 |
1 files changed, 11 insertions, 42 deletions
diff --git a/base/allocator/allocator_shim_default_dispatch_to_glibc.cc b/base/allocator/allocator_shim_default_dispatch_to_glibc.cc index 6f386d4cc0..02facbad2e 100644 --- a/base/allocator/allocator_shim_default_dispatch_to_glibc.cc +++ b/base/allocator/allocator_shim_default_dispatch_to_glibc.cc @@ -4,10 +4,6 @@ #include "base/allocator/allocator_shim.h" -#include <malloc.h> - -#include "base/compiler_specific.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. @@ -24,60 +20,33 @@ namespace { using base::allocator::AllocatorDispatch; -void* GlibcMalloc(const AllocatorDispatch*, size_t size, void* context) { - ALLOW_UNUSED_PARAM(context); +void* GlibcMalloc(const AllocatorDispatch*, size_t size) { return __libc_malloc(size); } -void* GlibcCalloc(const AllocatorDispatch*, - size_t n, - size_t size, - void* context) { - ALLOW_UNUSED_PARAM(context); +void* GlibcCalloc(const AllocatorDispatch*, size_t n, size_t size) { return __libc_calloc(n, size); } -void* GlibcRealloc(const AllocatorDispatch*, - void* address, - size_t size, - void* context) { - ALLOW_UNUSED_PARAM(context); +void* GlibcRealloc(const AllocatorDispatch*, void* address, size_t size) { return __libc_realloc(address, size); } -void* GlibcMemalign(const AllocatorDispatch*, - size_t alignment, - size_t size, - void* context) { - ALLOW_UNUSED_PARAM(context); +void* GlibcMemalign(const AllocatorDispatch*, size_t alignment, size_t size) { return __libc_memalign(alignment, size); } -void GlibcFree(const AllocatorDispatch*, void* address, void* context) { - ALLOW_UNUSED_PARAM(context); +void GlibcFree(const AllocatorDispatch*, void* address) { __libc_free(address); } -size_t GlibcGetSizeEstimate(const AllocatorDispatch*, - void* address, - void* context) { - // TODO(siggi, primiano): malloc_usable_size may need redirection in the - // presence of interposing shims that divert allocations. - ALLOW_UNUSED_PARAM(context); - 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 */ - &GlibcGetSizeEstimate, /* get_size_estimate_function */ - nullptr, /* batch_malloc_function */ - nullptr, /* batch_free_function */ - nullptr, /* free_definite_size_function */ - nullptr, /* next */ + &GlibcMalloc, /* alloc_function */ + &GlibcCalloc, /* alloc_zero_initialized_function */ + &GlibcMemalign, /* alloc_aligned_function */ + &GlibcRealloc, /* realloc_function */ + &GlibcFree, /* free_function */ + nullptr, /* next */ }; |