Allocate a page Note: in debug mode the size includes MI_PADDING_SIZE and might have overflowed.
| 856 | // Allocate a page |
| 857 | // Note: in debug mode the size includes MI_PADDING_SIZE and might have overflowed. |
| 858 | static mi_page_t* mi_find_page(mi_heap_t* heap, size_t size, size_t huge_alignment) mi_attr_noexcept { |
| 859 | // huge allocation? |
| 860 | const size_t req_size = size - MI_PADDING_SIZE; // correct for padding_size in case of an overflow on `size` |
| 861 | if mi_unlikely(req_size > (MI_MEDIUM_OBJ_SIZE_MAX - MI_PADDING_SIZE) || huge_alignment > 0) { |
| 862 | if mi_unlikely(req_size > PTRDIFF_MAX) { // we don't allocate more than PTRDIFF_MAX (see <https://sourceware.org/ml/libc-announce/2019/msg00001.html>) |
| 863 | _mi_error_message(EOVERFLOW, "allocation request is too large (%zu bytes)\n", req_size); |
| 864 | return NULL; |
| 865 | } |
| 866 | else { |
| 867 | return mi_large_huge_page_alloc(heap,size,huge_alignment); |
| 868 | } |
| 869 | } |
| 870 | else { |
| 871 | // otherwise find a page with free blocks in our size segregated queues |
| 872 | mi_assert_internal(size >= MI_PADDING_SIZE); |
no test coverage detected