| 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 | 6 |
| 7 // This translation unit defines a default dispatch for the allocator shim which | 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 | 8 // routes allocations to the original libc functions when using the link-time |
| 9 // -Wl,-wrap,malloc approach (see README.md). | 9 // -Wl,-wrap,malloc approach (see README.md). |
| 10 // The __real_X functions here are special symbols that the linker will relocate | 10 // The __real_X functions here are special symbols that the linker will relocate |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 | 39 |
| 40 void* RealMemalign(const AllocatorDispatch*, size_t alignment, size_t size) { | 40 void* RealMemalign(const AllocatorDispatch*, size_t alignment, size_t size) { |
| 41 return __real_memalign(alignment, size); | 41 return __real_memalign(alignment, size); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void RealFree(const AllocatorDispatch*, void* address) { | 44 void RealFree(const AllocatorDispatch*, void* address) { |
| 45 __real_free(address); | 45 __real_free(address); |
| 46 } | 46 } |
| 47 | 47 |
| 48 size_t RealSizeEstimate(const AllocatorDispatch*, void*) { |
| 49 // TODO(primiano): This should be redirected to malloc_usable_size or |
| 50 // the like. |
| 51 return 0; |
| 52 } |
| 53 |
| 48 } // namespace | 54 } // namespace |
| 49 | 55 |
| 50 const AllocatorDispatch AllocatorDispatch::default_dispatch = { | 56 const AllocatorDispatch AllocatorDispatch::default_dispatch = { |
| 51 &RealMalloc, /* alloc_function */ | 57 &RealMalloc, /* alloc_function */ |
| 52 &RealCalloc, /* alloc_zero_initialized_function */ | 58 &RealCalloc, /* alloc_zero_initialized_function */ |
| 53 &RealMemalign, /* alloc_aligned_function */ | 59 &RealMemalign, /* alloc_aligned_function */ |
| 54 &RealRealloc, /* realloc_function */ | 60 &RealRealloc, /* realloc_function */ |
| 55 &RealFree, /* free_function */ | 61 &RealFree, /* free_function */ |
| 56 nullptr, /* next */ | 62 &RealSizeEstimate, /* get_size_estimate_function */ |
| 63 nullptr, /* next */ |
| 57 }; | 64 }; |
| OLD | NEW |