Lines Matching refs:heap
54 static void move_up_lpt_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, in move_up_lpt_heap() argument
67 val2 = get_heap_comp_val(heap->arr[ppos], cat); in move_up_lpt_heap()
71 heap->arr[ppos]->hpos = hpos; in move_up_lpt_heap()
72 heap->arr[hpos] = heap->arr[ppos]; in move_up_lpt_heap()
73 heap->arr[ppos] = lprops; in move_up_lpt_heap()
91 static void adjust_lpt_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, in adjust_lpt_heap() argument
101 val2 = get_heap_comp_val(heap->arr[ppos], cat); in adjust_lpt_heap()
105 heap->arr[ppos]->hpos = hpos; in adjust_lpt_heap()
106 heap->arr[hpos] = heap->arr[ppos]; in adjust_lpt_heap()
107 heap->arr[ppos] = lprops; in adjust_lpt_heap()
113 val2 = get_heap_comp_val(heap->arr[ppos], cat); in adjust_lpt_heap()
125 if (cpos >= heap->cnt) in adjust_lpt_heap()
127 val2 = get_heap_comp_val(heap->arr[cpos], cat); in adjust_lpt_heap()
130 if (cpos + 1 < heap->cnt) { in adjust_lpt_heap()
131 val3 = get_heap_comp_val(heap->arr[cpos + 1], in adjust_lpt_heap()
136 heap->arr[cpos]->hpos = hpos; in adjust_lpt_heap()
137 heap->arr[hpos] = heap->arr[cpos]; in adjust_lpt_heap()
138 heap->arr[cpos] = lprops; in adjust_lpt_heap()
145 if (cpos >= heap->cnt) in adjust_lpt_heap()
147 val3 = get_heap_comp_val(heap->arr[cpos], cat); in adjust_lpt_heap()
150 heap->arr[cpos]->hpos = hpos; in adjust_lpt_heap()
151 heap->arr[hpos] = heap->arr[cpos]; in adjust_lpt_heap()
152 heap->arr[cpos] = lprops; in adjust_lpt_heap()
173 struct ubifs_lpt_heap *heap = &c->lpt_heap[cat - 1]; in add_to_lpt_heap() local
175 if (heap->cnt >= heap->max_cnt) { in add_to_lpt_heap()
184 ubifs_assert(cpos < heap->cnt); in add_to_lpt_heap()
187 val2 = get_heap_comp_val(heap->arr[cpos], cat); in add_to_lpt_heap()
191 lp = heap->arr[cpos]; in add_to_lpt_heap()
196 heap->arr[cpos] = lprops; in add_to_lpt_heap()
197 move_up_lpt_heap(c, heap, lprops, cat); in add_to_lpt_heap()
198 dbg_check_heap(c, heap, cat, lprops->hpos); in add_to_lpt_heap()
201 dbg_check_heap(c, heap, cat, -1); in add_to_lpt_heap()
204 lprops->hpos = heap->cnt++; in add_to_lpt_heap()
205 heap->arr[lprops->hpos] = lprops; in add_to_lpt_heap()
206 move_up_lpt_heap(c, heap, lprops, cat); in add_to_lpt_heap()
207 dbg_check_heap(c, heap, cat, lprops->hpos); in add_to_lpt_heap()
221 struct ubifs_lpt_heap *heap; in remove_from_lpt_heap() local
224 heap = &c->lpt_heap[cat - 1]; in remove_from_lpt_heap()
225 ubifs_assert(hpos >= 0 && hpos < heap->cnt); in remove_from_lpt_heap()
226 ubifs_assert(heap->arr[hpos] == lprops); in remove_from_lpt_heap()
227 heap->cnt -= 1; in remove_from_lpt_heap()
228 if (hpos < heap->cnt) { in remove_from_lpt_heap()
229 heap->arr[hpos] = heap->arr[heap->cnt]; in remove_from_lpt_heap()
230 heap->arr[hpos]->hpos = hpos; in remove_from_lpt_heap()
231 adjust_lpt_heap(c, heap, heap->arr[hpos], hpos, cat); in remove_from_lpt_heap()
233 dbg_check_heap(c, heap, cat, -1); in remove_from_lpt_heap()
252 struct ubifs_lpt_heap *heap; in lpt_heap_replace() local
255 heap = &c->lpt_heap[cat - 1]; in lpt_heap_replace()
256 heap->arr[hpos] = new_lprops; in lpt_heap_replace()
448 struct ubifs_lpt_heap *heap; in change_category() local
453 heap = &c->lpt_heap[new_cat - 1]; in change_category()
454 adjust_lpt_heap(c, heap, lprops, lprops->hpos, new_cat); in change_category()
763 struct ubifs_lpt_heap *heap; in ubifs_fast_find_free() local
767 heap = &c->lpt_heap[LPROPS_FREE - 1]; in ubifs_fast_find_free()
768 if (heap->cnt == 0) in ubifs_fast_find_free()
771 lprops = heap->arr[0]; in ubifs_fast_find_free()
934 struct ubifs_lpt_heap *heap = &c->lpt_heap[cat - 1]; in dbg_check_cats() local
936 for (i = 0; i < heap->cnt; i++) { in dbg_check_cats()
937 lprops = heap->arr[i]; in dbg_check_cats()
956 void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat, in dbg_check_heap() argument
964 for (i = 0; i < heap->cnt; i++) { in dbg_check_heap()
965 struct ubifs_lprops *lprops = heap->arr[i]; in dbg_check_heap()
990 lp = heap->arr[j]; in dbg_check_heap()
1005 ubifs_dump_heap(c, heap, cat); in dbg_check_heap()
1077 struct ubifs_lpt_heap *heap = &c->lpt_heap[cat - 1]; in scan_check_cb() local
1079 if ((lp->hpos != -1 && heap->arr[lp->hpos]->lnum != lnum) || in scan_check_cb()
1080 lp != heap->arr[lp->hpos]) { in scan_check_cb()