libcxx-mini: operator new will assert when alloc failed.
Signed-off-by: buyuer <dingddding@163.com>
This commit is contained in:
parent
40b1f0bee8
commit
59c9620842
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user