mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-04 22:49:32 +03:00
roll back commit 0aec6d93
on alignment >= size
as it breaks assertions in tensorflow
This commit is contained in:
parent
1909cfb346
commit
050e7cedf4
1 changed files with 3 additions and 3 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue