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

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

Issue 1719433002: Introduce allocator shim for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shim_traceintegration
Patch Set: Add readme changes, do NOT enabled by default in this cl Created 4 years, 8 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
7 // This translation unit defines a default dispatch for the allocator shim which
8 // routes allocations to the original libc functions when using the link-time
9 // -Wl,-wrap,malloc approach (see README.md).
10 // The __real_X functions here are special symbols that the linker will relocate
11 // against the real "X" undefined symbol, so that __real_malloc becomes the
12 // equivalent of what an undefined malloc symbol reference would have been.
13 // This is the counterpart of allocator_shim_override_linker_wrapped_symbols.h,
14 // which routes the __wrap_X functions into the shim.
15
16 extern "C" {
17 void* __real_malloc(size_t);
18 void* __real_calloc(size_t, size_t);
19 void* __real_realloc(void*, size_t);
20 void* __real_memalign(size_t, size_t);
21 void* __real_free(void*);
22 } // extern "C"
23
24 namespace {
25
26 using base::allocator::AllocatorDispatch;
27
28 void* RealMalloc(const AllocatorDispatch*, size_t size) {
29 return __real_malloc(size);
30 }
31
32 void* RealCalloc(const AllocatorDispatch*, size_t n, size_t size) {
33 return __real_calloc(n, size);
34 }
35
36 void* RealRealloc(const AllocatorDispatch*, void* address, size_t size) {
37 return __real_realloc(address, size);
38 }
39
40 void* RealMemalign(const AllocatorDispatch*, size_t alignment, size_t size) {
41 return __real_memalign(alignment, size);
42 }
43
44 void RealFree(const AllocatorDispatch*, void* address) {
45 __real_free(address);
46 }
47
48 } // namespace
49
50 const AllocatorDispatch AllocatorDispatch::default_dispatch = {
51 &RealMalloc, /* alloc_function */
52 &RealCalloc, /* alloc_zero_initialized_function */
53 &RealMemalign, /* alloc_aligned_function */
54 &RealRealloc, /* realloc_function */
55 &RealFree, /* free_function */
56 nullptr, /* next */
57 };
OLDNEW
« no previous file with comments | « base/allocator/allocator_shim.cc ('k') | base/allocator/allocator_shim_override_linker_wrapped_symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698