| 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 #include "base/allocator/allocator_shim.h" | 5 #include "base/allocator/allocator_shim.h" |
| 6 #include "base/allocator/allocator_shim_internals.h" | 6 #include "base/allocator/allocator_shim_internals.h" |
| 7 #include "third_party/tcmalloc/chromium/src/config.h" | 7 #include "third_party/tcmalloc/chromium/src/config.h" |
| 8 #include "third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h" | 8 #include "third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 using base::allocator::AllocatorDispatch; | 12 using base::allocator::AllocatorDispatch; |
| 13 | 13 |
| 14 void* TCMalloc(const AllocatorDispatch*, size_t size) { | 14 void* TCMalloc(const AllocatorDispatch*, size_t size, void* context) { |
| 15 return tc_malloc(size); | 15 return tc_malloc(size); |
| 16 } | 16 } |
| 17 | 17 |
| 18 void* TCCalloc(const AllocatorDispatch*, size_t n, size_t size) { | 18 void* TCCalloc(const AllocatorDispatch*, size_t n, size_t size, void* context) { |
| 19 return tc_calloc(n, size); | 19 return tc_calloc(n, size); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void* TCMemalign(const AllocatorDispatch*, size_t alignment, size_t size) { | 22 void* TCMemalign(const AllocatorDispatch*, |
| 23 size_t alignment, |
| 24 size_t size, |
| 25 void* context) { |
| 23 return tc_memalign(alignment, size); | 26 return tc_memalign(alignment, size); |
| 24 } | 27 } |
| 25 | 28 |
| 26 void* TCRealloc(const AllocatorDispatch*, void* address, size_t size) { | 29 void* TCRealloc(const AllocatorDispatch*, |
| 30 void* address, |
| 31 size_t size, |
| 32 void* context) { |
| 27 return tc_realloc(address, size); | 33 return tc_realloc(address, size); |
| 28 } | 34 } |
| 29 | 35 |
| 30 void TCFree(const AllocatorDispatch*, void* address) { | 36 void TCFree(const AllocatorDispatch*, void* address, void* context) { |
| 31 tc_free(address); | 37 tc_free(address); |
| 32 } | 38 } |
| 33 | 39 |
| 34 size_t TCGetSizeEstimate(const AllocatorDispatch*, void* address) { | 40 size_t TCGetSizeEstimate(const AllocatorDispatch*, |
| 41 void* address, |
| 42 void* context) { |
| 35 return tc_malloc_size(address); | 43 return tc_malloc_size(address); |
| 36 } | 44 } |
| 37 | 45 |
| 38 } // namespace | 46 } // namespace |
| 39 | 47 |
| 40 const AllocatorDispatch AllocatorDispatch::default_dispatch = { | 48 const AllocatorDispatch AllocatorDispatch::default_dispatch = { |
| 41 &TCMalloc, /* alloc_function */ | 49 &TCMalloc, /* alloc_function */ |
| 42 &TCCalloc, /* alloc_zero_initialized_function */ | 50 &TCCalloc, /* alloc_zero_initialized_function */ |
| 43 &TCMemalign, /* alloc_aligned_function */ | 51 &TCMemalign, /* alloc_aligned_function */ |
| 44 &TCRealloc, /* realloc_function */ | 52 &TCRealloc, /* realloc_function */ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 75 | 83 |
| 76 #if defined(__ANDROID__) | 84 #if defined(__ANDROID__) |
| 77 SHIM_ALWAYS_EXPORT size_t malloc_usable_size(const void* address) __THROW { | 85 SHIM_ALWAYS_EXPORT size_t malloc_usable_size(const void* address) __THROW { |
| 78 #else | 86 #else |
| 79 SHIM_ALWAYS_EXPORT size_t malloc_usable_size(void* address) __THROW { | 87 SHIM_ALWAYS_EXPORT size_t malloc_usable_size(void* address) __THROW { |
| 80 #endif | 88 #endif |
| 81 return tc_malloc_size(address); | 89 return tc_malloc_size(address); |
| 82 } | 90 } |
| 83 | 91 |
| 84 } // extern "C" | 92 } // extern "C" |
| OLD | NEW |