aboutsummaryrefslogtreecommitdiff
path: root/zencore/memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/memory.cpp')
-rw-r--r--zencore/memory.cpp3
1 files changed, 3 insertions, 0 deletions
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
}