2018-10-23 18:20:51 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2019-11-14 00:23:33 +01:00
|
|
|
#include <stdlib.h>
|
2022-09-15 18:43:50 +02:00
|
|
|
#include <new>
|
2018-10-23 18:20:51 +02:00
|
|
|
|
2019-12-13 04:27:44 -06:00
|
|
|
#if __cplusplus < 201103L
|
|
|
|
#define NOEXCEPT
|
|
|
|
#else /* >= C++11 */
|
|
|
|
#define NOEXCEPT noexcept
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2018-10-23 18:20:51 +02:00
|
|
|
void* operator new(size_t size)
|
|
|
|
{
|
2019-11-14 00:23:33 +01:00
|
|
|
return malloc(size);
|
2018-10-23 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void* operator new[](size_t size)
|
|
|
|
{
|
2019-11-14 00:23:33 +01:00
|
|
|
return malloc(size);
|
2018-10-23 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2022-09-15 18:26:05 +02:00
|
|
|
void* operator new(std::size_t size, const std::nothrow_t& tag) NOEXCEPT
|
|
|
|
{
|
|
|
|
return malloc(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void* operator new[](std::size_t size, const std::nothrow_t& tag) NOEXCEPT
|
|
|
|
{
|
|
|
|
return malloc(size);
|
|
|
|
}
|
|
|
|
|
2022-09-15 18:43:50 +02:00
|
|
|
#if __cplusplus >= 201703L
|
|
|
|
void* operator new(size_t size, std::align_val_t al)
|
|
|
|
{
|
|
|
|
return aligned_alloc(static_cast<size_t>(al), size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void* operator new[](std::size_t size, std::align_val_t al)
|
|
|
|
{
|
|
|
|
return aligned_alloc(static_cast<size_t>(al), size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void* operator new(std::size_t size, std::align_val_t al,
|
|
|
|
const std::nothrow_t&) NOEXCEPT
|
|
|
|
{
|
|
|
|
return aligned_alloc(static_cast<size_t>(al), size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void* operator new[](std::size_t size, std::align_val_t al,
|
|
|
|
const std::nothrow_t&) NOEXCEPT
|
|
|
|
{
|
|
|
|
return aligned_alloc(static_cast<size_t>(al), size);
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus >= 201703L */
|
|
|
|
|
2019-12-13 04:27:44 -06:00
|
|
|
void operator delete(void* ptr) NOEXCEPT
|
2018-10-23 18:20:51 +02:00
|
|
|
{
|
2019-11-14 00:23:33 +01:00
|
|
|
free(ptr);
|
2018-10-23 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2019-12-13 04:27:44 -06:00
|
|
|
void operator delete[](void* ptr) NOEXCEPT
|
2018-10-23 18:20:51 +02:00
|
|
|
{
|
2019-11-14 00:23:33 +01:00
|
|
|
free(ptr);
|
2018-10-23 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if (__cplusplus > 201103L)
|
2019-12-13 04:27:44 -06:00
|
|
|
void operator delete(void* ptr, size_t) NOEXCEPT
|
2018-10-23 18:20:51 +02:00
|
|
|
{
|
2019-11-14 00:23:33 +01:00
|
|
|
free(ptr);
|
2018-10-23 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2019-12-13 04:27:44 -06:00
|
|
|
void operator delete[](void* ptr, size_t) NOEXCEPT
|
2018-10-23 18:20:51 +02:00
|
|
|
{
|
2019-11-14 00:23:33 +01:00
|
|
|
free(ptr);
|
2018-10-23 18:20:51 +02:00
|
|
|
}
|
|
|
|
#endif // __cplusplus > 201103L
|