Skip to content

Commit c9ffe30

Browse files
committed
weaken alignment requirement to not need to be a multiple of sizeof(void*); see #246
1 parent bf6b781 commit c9ffe30

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/alloc-aligned.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ terms of the MIT license. A copy of the license can be found in the file
1717
static void* mi_heap_malloc_zero_aligned_at(mi_heap_t* const heap, const size_t size, const size_t alignment, const size_t offset, const bool zero) mi_attr_noexcept {
1818
// note: we don't require `size > offset`, we just guarantee that
1919
// the address at offset is aligned regardless of the allocated size.
20-
mi_assert(alignment > 0 && alignment % sizeof(void*) == 0);
21-
20+
mi_assert(alignment > 0);
2221
if (mi_unlikely(size > PTRDIFF_MAX)) return NULL; // we don't allocate more than PTRDIFF_MAX (see <https://sourceware.org/ml/libc-announce/2019/msg00001.html>)
2322
if (mi_unlikely(alignment==0 || !_mi_is_power_of_two(alignment))) return NULL; // require power-of-two (see <https://en.cppreference.com/w/c/memory/aligned_alloc>)
2423
const uintptr_t align_mask = alignment-1; // for any x, `(x & align_mask) == (x % alignment)`

0 commit comments

Comments
 (0)