Add placement new and new[] function.

N/A

Change-Id: I9f16f9c0c36f2619218a65d178100d54ced5f71b
Signed-off-by: 丁欣童 <dingxintong@xiaomi.com>
This commit is contained in:
丁欣童
2021-01-13 15:57:32 +08:00
committed by dingxintong
parent 32f3ddec8b
commit c1de1c563e
2 changed files with 30 additions and 0 deletions
+15
View File
@@ -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;
}
+15
View File
@@ -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;
}