Plasma Engine  2.0
Loading...
Searching...
No Matches
AllocPolicyAlignedHeap_posix.h
1
2PL_FORCE_INLINE void* plAllocPolicyAlignedHeap::Allocate(size_t uiSize, size_t uiAlign)
3{
4 // alignment has to be at least sizeof(void*) otherwise posix_memalign will fail
5 uiAlign = plMath::Max<size_t>(uiAlign, 16u);
6
7 void* ptr = nullptr;
8
9 int res = posix_memalign(&ptr, uiAlign, uiSize);
10 PL_IGNORE_UNUSED(res);
11 PL_ASSERT_DEV(res == 0, "posix_memalign failed with error: {0}", res);
12
13 PL_CHECK_ALIGNMENT(ptr, uiAlign);
14
15 return ptr;
16}
17
18PL_ALWAYS_INLINE void plAllocPolicyAlignedHeap::Deallocate(void* ptr)
19{
20 free(ptr);
21}
constexpr PL_ALWAYS_INLINE T Max(T f1, T f2)
Returns the greater value, f1 or f2.
Definition Math_inl.h:39