aligned_alloc: Permit alignment values smaller than sizeof(uintptr_t) (#671)

posix_memalign() requires alignment values of at least
sizeof(uintptr_t), but aligned_alloc() does not.  memalign() regressed
to require larger alignment in commit
6cbc50fe2c.

Fixes #668
This commit is contained in:
John Baldwin
2024-08-27 17:16:19 -04:00
committed by GitHub
parent 6af38acd94
commit fcad15456b

View File

@@ -145,8 +145,7 @@ namespace snmalloc::libc
inline void* memalign(size_t alignment, size_t size)
{
if (SNMALLOC_UNLIKELY(
alignment < sizeof(uintptr_t) || !bits::is_pow2(alignment)))
if (SNMALLOC_UNLIKELY(alignment == 0 || !bits::is_pow2(alignment)))
{
return set_error(EINVAL);
}