diff options
author | Matthijs Kooijman <matthijs@stdin.nl> | 2020-09-17 17:22:41 +0200 |
---|---|---|
committer | Matthijs Kooijman <matthijs@stdin.nl> | 2020-09-17 20:01:29 +0200 |
commit | 4e469e0c83799ad6d3698e7cfa51ef8a5f2a2c76 (patch) | |
tree | e7e95c134f2bc13e49a5b3b04e52c31e52bd3fca /cores/arduino | |
parent | 07b6bd188f2395551fbd5eee3c3ca7ca3769bbbc (diff) |
Allow overriding selected operator new and delete functions
This makes these functions weak, so that a sketch or library can replace
them. This does not apply to all of these operators, only for the ones
that the C++ standard specifies as replaceable.
Diffstat (limited to 'cores/arduino')
-rw-r--r-- | cores/arduino/new | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/cores/arduino/new b/cores/arduino/new index 3599571..fb60927 100644 --- a/cores/arduino/new +++ b/cores/arduino/new @@ -33,25 +33,25 @@ namespace std { new_handler get_new_handler() noexcept; } // namespace std -void * operator new(size_t size); -void * operator new[](size_t size); +[[gnu::weak]] void * operator new(size_t size); +[[gnu::weak]] void * operator new[](size_t size); -void * operator new(size_t size, const std::nothrow_t tag) noexcept; -void * operator new[](size_t size, const std::nothrow_t& tag) noexcept; +[[gnu::weak]] void * operator new(size_t size, const std::nothrow_t tag) noexcept; +[[gnu::weak]] void * operator new[](size_t size, const std::nothrow_t& tag) noexcept; void * operator new(size_t size, void *place) noexcept; void * operator new[](size_t size, void *place) noexcept; -void operator delete(void * ptr) noexcept; -void operator delete[](void * ptr) noexcept; +[[gnu::weak]] void operator delete(void * ptr) noexcept; +[[gnu::weak]] void operator delete[](void * ptr) noexcept; #if __cplusplus >= 201402L -void operator delete(void* ptr, size_t size) noexcept; -void operator delete[](void * ptr, size_t size) noexcept; +[[gnu::weak]] void operator delete(void* ptr, size_t size) noexcept; +[[gnu::weak]] void operator delete[](void * ptr, size_t size) noexcept; #endif // __cplusplus >= 201402L -void operator delete(void* ptr, const std::nothrow_t& tag) noexcept; -void operator delete[](void* ptr, const std::nothrow_t& tag) noexcept; +[[gnu::weak]] void operator delete(void* ptr, const std::nothrow_t& tag) noexcept; +[[gnu::weak]] void operator delete[](void* ptr, const std::nothrow_t& tag) noexcept; void operator delete(void* ptr, void* place) noexcept; void operator delete[](void* ptr, void* place) noexcept; |