MCPcopy Create free account
hub / github.com/F-Stack/f-stack / find_suitable_element

Function find_suitable_element

dpdk/lib/eal/common/malloc_heap.c:149–175  ·  view source on GitHub ↗

* Iterates through the freelist for a heap to find a free element * which can store data of the required size and with the requested alignment. * If size is 0, find the biggest available elem. * Returns null on failure, or pointer to element on success. */

Source from the content-addressed store, hash-verified

147 * Returns null on failure, or pointer to element on success.
148 */
149static struct malloc_elem *
150find_suitable_element(struct malloc_heap *heap, size_t size,
151 unsigned int flags, size_t align, size_t bound, bool contig)
152{
153 size_t idx;
154 struct malloc_elem *elem, *alt_elem = NULL;
155
156 for (idx = malloc_elem_free_list_index(size);
157 idx < RTE_HEAP_NUM_FREELISTS; idx++) {
158 for (elem = LIST_FIRST(&heap->free_head[idx]);
159 !!elem; elem = LIST_NEXT(elem, free_list)) {
160 if (malloc_elem_can_hold(elem, size, align, bound,
161 contig)) {
162 if (check_hugepage_sz(flags,
163 elem->msl->page_sz))
164 return elem;
165 if (alt_elem == NULL)
166 alt_elem = elem;
167 }
168 }
169 }
170
171 if (flags & RTE_MEMZONE_SIZE_HINT_ONLY)
172 return alt_elem;
173
174 return NULL;
175}
176
177/*
178 * Iterates through the freelist for a heap to find a free element with the

Callers 3

heap_allocFunction · 0.85
alloc_pages_on_heapFunction · 0.85
alloc_more_mem_on_socketFunction · 0.85

Calls 3

malloc_elem_can_holdFunction · 0.85
check_hugepage_szFunction · 0.85

Tested by

no test coverage detected