From 4e469e0c83799ad6d3698e7cfa51ef8a5f2a2c76 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 17 Sep 2020 17:22:41 +0200 Subject: 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. --- cores/arduino/new | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'cores/arduino') 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; -- cgit v1.2.3-18-g5258