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 <nuttx/config.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
@ -68,6 +69,8 @@ FAR void *operator new(std::size_t nbytes)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DEBUGASSERT(alloc != nullptr);
|
||||||
|
|
||||||
// Return the allocated value
|
// Return the allocated value
|
||||||
|
|
||||||
return alloc;
|
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)
|
FAR void *operator new(std::size_t nbytes, FAR void *ptr)
|
||||||
{
|
{
|
||||||
|
DEBUGASSERT(ptr != nullptr);
|
||||||
#ifdef CONFIG_DEBUG_ERROR
|
|
||||||
if (ptr == 0)
|
|
||||||
{
|
|
||||||
_err("ERROR: Failed to placement new\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Return the ptr pointer
|
// Return the ptr pointer
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
@ -76,6 +77,8 @@ FAR void *operator new[](std::size_t nbytes)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DEBUGASSERT(alloc != nullptr);
|
||||||
|
|
||||||
// Return the allocated value
|
// Return the allocated value
|
||||||
|
|
||||||
return alloc;
|
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)
|
FAR void *operator new[](std::size_t nbytes, FAR void *ptr)
|
||||||
{
|
{
|
||||||
|
DEBUGASSERT(ptr != nullptr);
|
||||||
#ifdef CONFIG_DEBUG_ERROR
|
|
||||||
if (ptr == 0)
|
|
||||||
{
|
|
||||||
_err("ERROR: Failed to placement new[]\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Return the ptr pointer
|
// Return the ptr pointer
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user