roll back commit on `alignment >= size` as it breaks assertions in tensorflow
@@ -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 <https://sourceware.org/ml/libc-announce/2019/msg00001.html>)
- // 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) {
