From fcad15456b04ec59e2ab7df7ba27a4d8933c7f6a Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 27 Aug 2024 17:16:19 -0400 Subject: [PATCH] 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 6cbc50fe2c255b5b47ea63f4cf759a6a20f6e7a6. Fixes #668 --- src/snmalloc/global/libc.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/snmalloc/global/libc.h b/src/snmalloc/global/libc.h index 700fd390..2a6db38a 100644 --- a/src/snmalloc/global/libc.h +++ b/src/snmalloc/global/libc.h @@ -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); }