mirror of
https://github.com/apache/nuttx.git
synced 2026-08-20 21:18:23 +00:00
Add placement new and new[] function.
N/A Change-Id: I9f16f9c0c36f2619218a65d178100d54ced5f71b Signed-off-by: 丁欣童 <dingxintong@xiaomi.com>
This commit is contained in:
parent
32f3ddec8b
commit
c1de1c563e
2 changed files with 30 additions and 0 deletions
|
|
@ -88,3 +88,18 @@ FAR void *operator new(std::size_t nbytes)
|
|||
|
||||
return alloc;
|
||||
}
|
||||
|
||||
FAR void *operator new(std::size_t nbytes, FAR void *ptr)
|
||||
{
|
||||
|
||||
#ifdef CONFIG_DEBUG_ERROR
|
||||
if (ptr == nullptr)
|
||||
{
|
||||
_err("ERROR: Failed to placement new\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Return the ptr pointer
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
|
@ -96,3 +96,18 @@ FAR void *operator new[](std::size_t nbytes)
|
|||
|
||||
return alloc;
|
||||
}
|
||||
|
||||
FAR void *operator new[](std::size_t nbytes, FAR void *ptr)
|
||||
{
|
||||
|
||||
#ifdef CONFIG_DEBUG_ERROR
|
||||
if (ptr == nullptr)
|
||||
{
|
||||
_err("ERROR: Failed to placement new[]\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Return the ptr pointer
|
||||
|
||||
return ptr;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue