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:
@ -36,28 +36,44 @@ extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
|
|||||||
|
|
||||||
// overwrite weak operators new/new[] definitions
|
// overwrite weak operators new/new[] definitions
|
||||||
|
|
||||||
void *operator new(size_t size)
|
void* operator new(size_t size)
|
||||||
{
|
{
|
||||||
void *ret = malloc(size);
|
void *ret = malloc(size);
|
||||||
if (0 != size && 0 == ret) {
|
if (0 != size && 0 == ret) {
|
||||||
umm_last_fail_alloc_addr = __builtin_return_address(0);
|
umm_last_fail_alloc_addr = __builtin_return_address(0);
|
||||||
umm_last_fail_alloc_size = size;
|
umm_last_fail_alloc_size = size;
|
||||||
#if defined(NEW_OOM_ABORT)
|
|
||||||
__unhandled_exception(PSTR("OOM"));
|
__unhandled_exception(PSTR("OOM"));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *operator new[](size_t size)
|
void* operator new[](size_t size)
|
||||||
{
|
{
|
||||||
void *ret = malloc(size);
|
void *ret = malloc(size);
|
||||||
if (0 != size && 0 == ret) {
|
if (0 != size && 0 == ret) {
|
||||||
umm_last_fail_alloc_addr = __builtin_return_address(0);
|
umm_last_fail_alloc_addr = __builtin_return_address(0);
|
||||||
umm_last_fail_alloc_size = size;
|
umm_last_fail_alloc_size = size;
|
||||||
#if defined(NEW_OOM_ABORT)
|
|
||||||
__unhandled_exception(PSTR("OOM"));
|
__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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user