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

Function malloc_elem_hide_region

dpdk/lib/eal/common/malloc_elem.c:608–658  ·  view source on GitHub ↗

assume all checks were already done */

Source from the content-addressed store, hash-verified

606
607/* assume all checks were already done */
608void
609malloc_elem_hide_region(struct malloc_elem *elem, void *start, size_t len)
610{
611 struct malloc_elem *hide_start, *hide_end, *prev, *next;
612 size_t len_before, len_after;
613
614 hide_start = start;
615 hide_end = RTE_PTR_ADD(start, len);
616
617 prev = elem->prev;
618 next = elem->next;
619
620 /* we cannot do anything with non-adjacent elements */
621 if (next && next_elem_is_adjacent(elem)) {
622 len_after = RTE_PTR_DIFF(next, hide_end);
623 if (len_after >= MALLOC_ELEM_OVERHEAD + MIN_DATA_SIZE) {
624 asan_clear_split_alloczone(hide_end);
625
626 /* split after */
627 split_elem(elem, hide_end);
628
629 malloc_elem_free_list_insert(hide_end);
630 } else if (len_after > 0) {
631 RTE_LOG(ERR, EAL, "Unaligned element, heap is probably corrupt\n");
632 return;
633 }
634 }
635
636 /* we cannot do anything with non-adjacent elements */
637 if (prev && prev_elem_is_adjacent(elem)) {
638 len_before = RTE_PTR_DIFF(hide_start, elem);
639 if (len_before >= MALLOC_ELEM_OVERHEAD + MIN_DATA_SIZE) {
640 asan_clear_split_alloczone(hide_start);
641
642 /* split before */
643 split_elem(elem, hide_start);
644
645 prev = elem;
646 elem = hide_start;
647
648 malloc_elem_free_list_insert(prev);
649 } else if (len_before > 0) {
650 RTE_LOG(ERR, EAL, "Unaligned element, heap is probably corrupt\n");
651 return;
652 }
653 }
654
655 asan_clear_alloczone(elem);
656
657 remove_elem(elem);
658}
659
660/*
661 * attempt to resize a malloc_elem by expanding into any free space

Callers 3

rollback_expand_heapFunction · 0.85
malloc_heap_freeFunction · 0.85
destroy_elemFunction · 0.85

Calls 7

next_elem_is_adjacentFunction · 0.85
split_elemFunction · 0.85
prev_elem_is_adjacentFunction · 0.85
asan_clear_alloczoneFunction · 0.85
remove_elemFunction · 0.85

Tested by

no test coverage detected