* 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. */
| 147 | * Returns null on failure, or pointer to element on success. |
| 148 | */ |
| 149 | static struct malloc_elem * |
| 150 | find_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 |
no test coverage detected