mirror of
https://github.com/apache/nuttx.git
synced 2026-08-10 23:15:15 +00:00
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
2 changed files with 8 additions and 14 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue