aboutsummaryrefslogtreecommitdiff
path: root/zencore/memory.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2022-01-05 12:10:03 +0100
committerMartin Ridgers <[email protected]>2022-01-05 15:15:47 +0100
commit0798fee1c8af3c3900cda78e23601f2dde78532c (patch)
treef86b43a973166561f013e45704a680541ccf8b6a /zencore/memory.cpp
parentMerge branch 'main' of https://github.com/EpicGames/zen (diff)
downloadzen-0798fee1c8af3c3900cda78e23601f2dde78532c.tar.xz
zen-0798fee1c8af3c3900cda78e23601f2dde78532c.zip
aligned_alloc() states that size must be a multiple of alignment
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
}