From 050e7cedf453e05eb4e498786b467b599a154f9b Mon Sep 17 00:00:00 2001 From: daan Date: Wed, 11 Sep 2019 15:48:44 -0700 Subject: [PATCH] roll back commit 0aec6d93 on `alignment >= size` as it breaks assertions in tensorflow --- src/alloc-aligned.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/alloc-aligned.c b/src/alloc-aligned.c index cf89e274..b629d57b 100644 --- a/src/alloc-aligned.c +++ b/src/alloc-aligned.c @@ -17,10 +17,10 @@ terms of the MIT license. A copy of the license can be found in the file static void* mi_heap_malloc_zero_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset, bool zero) mi_attr_noexcept { // note: we don't require `size > offset`, we just guarantee that // the address at offset is aligned regardless of the allocated size. - mi_assert(alignment > 0 && alignment % sizeof(uintptr_t) == 0); + mi_assert(alignment > 0 && alignment % sizeof(void*) == 0); if (mi_unlikely(size > PTRDIFF_MAX)) return NULL; // we don't allocate more than PTRDIFF_MAX (see ) - // note: we require that alignment is smaller than `size` - if (mi_unlikely(alignment <= sizeof(uintptr_t) || alignment >= size)) return _mi_heap_malloc_zero(heap,size,zero); + // use regular allocation if it is guaranteed to fit the alignment constraints + if (mi_unlikely(alignment <= sizeof(void*))) return _mi_heap_malloc_zero(heap, size, zero); // try if there is a current small block with just the right alignment if (size <= MI_SMALL_SIZE_MAX) {