Skip to content

Commit

Permalink
Fix compile error with aligned_alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex St-Onge authored and Segfault1602 committed Aug 31, 2024
1 parent 3e0527f commit e683c4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/phaseshapers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
}
Expand Down
16 changes: 13 additions & 3 deletions tests/perf/aligned_perf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<T*>(ptr);
}

template <typename T>
void AlignedFree(T* ptr)
{
#ifdef _MSC_VER
_aligned_free(ptr);
#else
std::free(ptr);
#endif
}
} // namespace

TEST_CASE("Aligned")
Expand Down Expand Up @@ -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);
}

0 comments on commit e683c4a

Please sign in to comment.