libcxx-mini: operator new will assert when alloc failed.

Signed-off-by: buyuer <dingddding@163.com>
This commit is contained in:
buyuer 2022-01-11 14:07:27 +08:00 committed by Petro Karashchenko
parent 40b1f0bee8
commit 59c9620842
2 changed files with 8 additions and 14 deletions

View File

@ -22,6 +22,7 @@
//***************************************************************************
#include <nuttx/config.h>
#include <assert.h>
#include <cstddef>
#include <debug.h>
@ -68,6 +69,8 @@ FAR void *operator new(std::size_t nbytes)
}
#endif
DEBUGASSERT(alloc != nullptr);
// Return the allocated value
return alloc;
@ -75,13 +78,7 @@ FAR void *operator new(std::size_t nbytes)
FAR void *operator new(std::size_t nbytes, FAR void *ptr)
{
#ifdef CONFIG_DEBUG_ERROR
if (ptr == 0)
{
_err("ERROR: Failed to placement new\n");
}
#endif
DEBUGASSERT(ptr != nullptr);
// Return the ptr pointer

View File

@ -22,6 +22,7 @@
//***************************************************************************
#include <nuttx/config.h>
#include <assert.h>
#include <cstddef>
#include <debug.h>
@ -76,6 +77,8 @@ FAR void *operator new[](std::size_t nbytes)
}
#endif
DEBUGASSERT(alloc != nullptr);
// Return the allocated value
return alloc;
@ -83,13 +86,7 @@ FAR void *operator new[](std::size_t nbytes)
FAR void *operator new[](std::size_t nbytes, FAR void *ptr)
{
#ifdef CONFIG_DEBUG_ERROR
if (ptr == 0)
{
_err("ERROR: Failed to placement new[]\n");
}
#endif
DEBUGASSERT(ptr != nullptr);
// Return the ptr pointer