| 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 #ifdef BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_CPP_SYMBOLS_H_ | 5 #ifdef BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_CPP_SYMBOLS_H_ |
| 6 #error This header is meant to be included only once by allocator_shim.cc | 6 #error This header is meant to be included only once by allocator_shim.cc |
| 7 #endif | 7 #endif |
| 8 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_CPP_SYMBOLS_H_ | 8 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_CPP_SYMBOLS_H_ |
| 9 | 9 |
| 10 // Preempt the default new/delete C++ symbols so they call the shim entry | 10 // Preempt the default new/delete C++ symbols so they call the shim entry |
| 11 // points. This file is strongly inspired by tcmalloc's | 11 // points. This file is strongly inspired by tcmalloc's |
| 12 // libc_override_redefine.h. | 12 // libc_override_redefine.h. |
| 13 | 13 |
| 14 #include <new> | 14 #include <new> |
| 15 | 15 |
| 16 #include "base/allocator/allocator_shim_internals.h" | 16 #include "base/allocator/allocator_shim_internals.h" |
| 17 | 17 |
| 18 SHIM_ALWAYS_EXPORT void* operator new(size_t size) { | 18 SHIM_ALWAYS_EXPORT void* operator new(size_t size) { |
| 19 return ShimCppNew(size); | 19 return ShimCppNew(size); |
| 20 } | 20 } |
| 21 | 21 |
| 22 #if defined(_LIBCPP_COUNTING_ALLOCATOR) |
| 23 SHIM_ALWAYS_EXPORT void* operator new(size_t size, std::new_tag tag) { |
| 24 return ShimTaggedCppNew(size, tag); |
| 25 } |
| 26 #endif |
| 27 |
| 22 SHIM_ALWAYS_EXPORT void operator delete(void* p) __THROW { | 28 SHIM_ALWAYS_EXPORT void operator delete(void* p) __THROW { |
| 23 ShimCppDelete(p); | 29 ShimCppDelete(p); |
| 24 } | 30 } |
| 25 | 31 |
| 26 SHIM_ALWAYS_EXPORT void* operator new[](size_t size) { | 32 SHIM_ALWAYS_EXPORT void* operator new[](size_t size) { |
| 27 return ShimCppNew(size); | 33 return ShimCppNew(size); |
| 28 } | 34 } |
| 29 | 35 |
| 30 SHIM_ALWAYS_EXPORT void operator delete[](void* p) __THROW { | 36 SHIM_ALWAYS_EXPORT void operator delete[](void* p) __THROW { |
| 31 ShimCppDelete(p); | 37 ShimCppDelete(p); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 } | 48 } |
| 43 | 49 |
| 44 SHIM_ALWAYS_EXPORT void operator delete(void* p, const std::nothrow_t&) __THROW
{ | 50 SHIM_ALWAYS_EXPORT void operator delete(void* p, const std::nothrow_t&) __THROW
{ |
| 45 ShimCppDelete(p); | 51 ShimCppDelete(p); |
| 46 } | 52 } |
| 47 | 53 |
| 48 SHIM_ALWAYS_EXPORT void operator delete[](void* p, | 54 SHIM_ALWAYS_EXPORT void operator delete[](void* p, |
| 49 const std::nothrow_t&) __THROW { | 55 const std::nothrow_t&) __THROW { |
| 50 ShimCppDelete(p); | 56 ShimCppDelete(p); |
| 51 } | 57 } |
| OLD | NEW |