MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / mi_find_page

Function mi_find_page

3rd/mimalloc-2.0.9/src/page.c:858–869  ·  view source on GitHub ↗

Allocate a page Note: in debug mode the size includes MI_PADDING_SIZE and might have overflowed.

Source from the content-addressed store, hash-verified

856// Allocate a page
857// Note: in debug mode the size includes MI_PADDING_SIZE and might have overflowed.
858static 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);

Callers 1

page.cFile · 0.85

Calls 3

mi_unlikelyFunction · 0.85
_mi_error_messageFunction · 0.85
mi_large_huge_page_allocFunction · 0.85

Tested by

no test coverage detected