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

Side by Side Diff: base/allocator/allocator_shim_default_dispatch_to_tcmalloc.cc

Issue 1675143004: Allocator shim skeleton + Linux impl behind a build flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shim_exp_flag
Patch Set: Make self the 1st arg Created 4 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/allocator/allocator_shim.h"
6 #include "base/allocator/allocator_shim_internals.h"
7 #include "third_party/tcmalloc/chromium/src/config.h"
8 #include "third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h"
9
10 namespace {
11
12 using base::allocator::AllocatorDispatch;
13
14 void* TCMalloc(const AllocatorDispatch*, size_t size) {
15 return tc_malloc(size);
16 }
17
18 void* TCCalloc(const AllocatorDispatch*, size_t n, size_t size) {
19 return tc_calloc(n, size);
20 }
21
22 void* TCMemalign(const AllocatorDispatch*, size_t alignment, size_t size) {
23 return tc_memalign(alignment, size);
24 }
25
26 void* TCRealloc(const AllocatorDispatch*, void* address, size_t size) {
27 return tc_realloc(address, size);
28 }
29
30 void TCFree(const AllocatorDispatch*, void* address) {
31 tc_free(address);
32 }
33
34 } // namespace
35
36 const AllocatorDispatch AllocatorDispatch::default_dispatch = {
37 &TCMalloc, /* alloc_function */
38 &TCCalloc, /* alloc_zero_initialized_function */
39 &TCMemalign, /* alloc_aligned_function */
40 &TCRealloc, /* realloc_function */
41 &TCFree, /* free_function */
42 nullptr, /* next */
43 };
44
45 // In the case of tcmalloc we have also to route the diagnostic symbols,
46 // which are not part of the unified shim layer, to tcmalloc for consistency.
47
48 extern "C" {
49
50 SHIM_ALWAYS_EXPORT void malloc_stats(void) __THROW {
51 return tc_malloc_stats();
52 }
53
54 SHIM_ALWAYS_EXPORT int mallopt(int cmd, int value) __THROW {
55 return tc_mallopt(cmd, value);
56 }
57
58 #ifdef HAVE_STRUCT_MALLINFO
59 SHIM_ALWAYS_EXPORT struct mallinfo mallinfo(void) __THROW {
60 return tc_mallinfo();
61 }
62 #endif
63
64 SHIM_ALWAYS_EXPORT size_t malloc_size(void* address) __THROW {
65 return tc_malloc_size(address);
66 }
67
68 #if defined(__ANDROID__)
69 SHIM_ALWAYS_EXPORT size_t malloc_usable_size(const void* address) __THROW {
70 #else
71 SHIM_ALWAYS_EXPORT size_t malloc_usable_size(void* address) __THROW {
72 #endif
73 return tc_malloc_size(address);
74 }
75
76 } // extern "C"
OLDNEW
« no previous file with comments | « base/allocator/allocator_shim_default_dispatch_to_glibc.cc ('k') | base/allocator/allocator_shim_internals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698