Add placement new and new[] function.

Signed-off-by: dingxintong <dingddding@163.com>
This commit is contained in:
dingxintong 2021-01-13 20:10:25 +08:00 committed by Xiang Xiao
parent 8e4397968c
commit c618d0447b
2 changed files with 30 additions and 0 deletions

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;
}

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;
}