From 0798fee1c8af3c3900cda78e23601f2dde78532c Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Wed, 5 Jan 2022 12:10:03 +0100 Subject: aligned_alloc() states that size must be a multiple of alignment --- zencore/memory.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'zencore/memory.cpp') diff --git a/zencore/memory.cpp b/zencore/memory.cpp index 7f194fa8c..c50d63a1d 100644 --- a/zencore/memory.cpp +++ b/zencore/memory.cpp @@ -29,6 +29,9 @@ AlignedAllocImpl(size_t size, size_t alignment) # endif #else // posix_memalign(&Ret, Alignment, Size); // Apple, AndroidApi<28 + // aligned_alloc() states that size must be a multiple of alignment. Some + // platforms return null if this requirement isn't met. + size = (size + alignment - 1) & ~(alignment - 1); return std::aligned_alloc(alignment, size); #endif } -- cgit v1.2.3