From e683c4a77cc4283c67940ea9a2481f2c72716d72 Mon Sep 17 00:00:00 2001 From: Alex St-Onge Date: Sat, 31 Aug 2024 15:11:38 -0400 Subject: [PATCH] Fix compile error with aligned_alloc --- src/phaseshapers.cpp | 4 ++-- tests/perf/aligned_perf.cpp | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/phaseshapers.cpp b/src/phaseshapers.cpp index f718e61..21d9ea0 100644 --- a/src/phaseshapers.cpp +++ b/src/phaseshapers.cpp @@ -204,7 +204,7 @@ void Phaseshaper::ProcessBlock(float* out, size_t size) } else { - memset(w2_buffer, 0, remaining * sizeof(float)); + std::memset(w2_buffer, 0, remaining * sizeof(float)); } for (size_t j = 0; j < remaining; ++j) @@ -458,7 +458,7 @@ void Phaseshaper::ProcessWaveBlock(const float* p, float* out, size_t size, Wave ProcessRippleBlock(p, out, size, gain); break; default: - memset(out, 0, size * sizeof(float)); + std::memset(out, 0, size * sizeof(float)); break; } } diff --git a/tests/perf/aligned_perf.cpp b/tests/perf/aligned_perf.cpp index 734f94b..a381654 100644 --- a/tests/perf/aligned_perf.cpp +++ b/tests/perf/aligned_perf.cpp @@ -18,10 +18,20 @@ T* AlignedAlloc(size_t size, size_t alignment) #ifdef _MSC_VER ptr = _aligned_malloc(size * sizeof(T), alignment); #else - ptr = aligned_alloc(alignment, size * sizeof(T)); + ptr = std::aligned_alloc(alignment, size * sizeof(T)); #endif return static_cast(ptr); } + +template +void AlignedFree(T* ptr) +{ +#ifdef _MSC_VER + _aligned_free(ptr); +#else + std::free(ptr); +#endif +} } // namespace TEST_CASE("Aligned") @@ -87,6 +97,6 @@ TEST_CASE("Aligned") CHECK(data_in_aligned[i] == data_out_aligned[i]); } - _aligned_free(data_in_aligned); - _aligned_free(data_out_aligned); + AlignedFree(data_in_aligned); + AlignedFree(data_out_aligned); } \ No newline at end of file