diff --git a/src/common/fifo_queue.h b/src/common/fifo_queue.h index 1206ee66e..e10305885 100644 --- a/src/common/fifo_queue.h +++ b/src/common/fifo_queue.h @@ -5,7 +5,11 @@ #include #include -#include // _aligned_malloc, memalign +#ifdef _MSC_VER +#include // _aligned_malloc +#else +#include // posix_memalign +#endif template class FIFOQueue @@ -183,7 +187,8 @@ public: #ifdef _MSC_VER this->m_ptr = static_cast(_aligned_malloc(sizeof(T) * CAPACITY, ALIGNMENT)); #else - this->m_ptr = static_cast(memalign(ALIGNMENT, sizeof(T) * CAPACITY)); + if (posix_memalign(reinterpret_cast(&this->m_ptr), ALIGNMENT, sizeof(T) * CAPACITY) != 0) + this->m_ptr = nullptr; #endif } else