#pragma once #ifdef USE_USER_HELPERS #include "canard_helpers_user.h" #endif #ifndef NOINLINE_FUNC #define NOINLINE_FUNC __attribute__((noinline)) #endif // define malloc and free #ifndef CANARD_MALLOC #include #include #include #define CANARD_MALLOC malloc #define CANARD_FREE free #endif namespace Canard { template T* allocate(Args...args) { auto ret = CANARD_MALLOC(sizeof(T)); if (ret == nullptr) { return nullptr; } memset(ret, 0, sizeof(T)); return new(ret) T(args...); } template void deallocate(T* ptr) { if (ptr == nullptr) { return; } ptr->~T(); CANARD_FREE(ptr); } }