1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-17 12:02:15 +03:00

overwrite weak new (std::nothrow) calls

This commit is contained in:
david gauchard
2020-08-24 22:42:29 +02:00
parent 2b6423edcc
commit c111713208

View File

@ -42,9 +42,7 @@ void *operator new(size_t size)
if (0 != size && 0 == ret) {
umm_last_fail_alloc_addr = __builtin_return_address(0);
umm_last_fail_alloc_size = size;
#if defined(NEW_OOM_ABORT)
__unhandled_exception(PSTR("OOM"));
#endif
}
return ret;
}
@ -55,9 +53,27 @@ void *operator new[](size_t size)
if (0 != size && 0 == ret) {
umm_last_fail_alloc_addr = __builtin_return_address(0);
umm_last_fail_alloc_size = size;
#if defined(NEW_OOM_ABORT)
__unhandled_exception(PSTR("OOM"));
#endif
}
return ret;
}
void* operator new (size_t size, const std::nothrow_t&)
{
void *ret = malloc(size);
if (0 != size && 0 == ret) {
umm_last_fail_alloc_addr = __builtin_return_address(0);
umm_last_fail_alloc_size = size;
}
return ret;
}
void* operator new[] (size_t size, const std::nothrow_t&)
{
void *ret = malloc(size);
if (0 != size && 0 == ret) {
umm_last_fail_alloc_addr = __builtin_return_address(0);
umm_last_fail_alloc_size = size;
}
return ret;
}