Skip to content

Commit

Permalink
aligned_alloc: Permit alignment values smaller than sizeof(uintptr_t) (
Browse files Browse the repository at this point in the history
…#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
6cbc50f.

Fixes #668
  • Loading branch information
bsdjhb authored Aug 27, 2024
1 parent 6af38ac commit fcad154
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/snmalloc/global/libc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit fcad154

Please sign in to comment.