Skip to content

Commit

Permalink
Aligned Alloc fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinchowdhury18 committed Apr 21, 2024
1 parent 8253a93 commit cf53b11
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/common/chowdsp_core/Memory/chowdsp_AlignedAlloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ inline void aligned_free (void* data)
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
#endif

return std::aligned_alloc (alignment, size);
// size is required to be a multiple of alignment!
const auto size_padded = ((size + alignment - 1) / alignment) * alignment;
return std::aligned_alloc (alignment, size_padded);

#ifdef __clang__
#pragma clang diagnostic pop
Expand Down

0 comments on commit cf53b11

Please sign in to comment.