Lines Matching defs:hole

52    util_vma_foreach_hole_safe(hole, heap)
53 free(hole);
61 util_vma_foreach_hole(hole, heap) {
62 assert(hole->offset > 0);
63 assert(hole->size > 0);
65 if (&hole->link == heap->holes.next) {
66 /* This must be the top-most hole. Assert that, if it overflows, it
69 assert(hole->size + hole->offset == 0 ||
70 hole->size + hole->offset > hole->offset);
72 /* This is not the top-most hole so it must not overflow and, in
73 * fact, must be strictly lower than the top-most hole. If
74 * hole->size + hole->offset == prev_offset, then we failed to join
77 assert(hole->size + hole->offset > hole->offset &&
78 hole->size + hole->offset < prev_offset);
80 prev_offset = hole->offset;
97 util_vma_foreach_hole_safe(hole, heap) {
98 if (size > hole->size)
102 * size can be without going over the top of the hole.
105 * hole->size + hole->offset can only overflow to 0 and size > 0.
107 uint64_t offset = (hole->size - size) + hole->offset;
110 * from the top of the hole and not the bottom.
114 if (offset < hole->offset)
117 if (offset == hole->offset && size == hole->size) {
118 /* Just get rid of the hole. */
119 list_del(&hole->link);
120 free(hole);
125 assert(offset - hole->offset <= hole->size - size);
126 uint64_t waste = (hole->size - size) - (offset - hole->offset);
128 /* We allocated at the top. Shrink the hole down. */
129 hole->size -= size;
134 if (offset == hole->offset) {
135 /* We allocated at the bottom. Shrink the hole up. */
136 hole->offset += size;
137 hole->size -= size;
142 /* We allocated in the middle. We need to split the old hole into two
145 struct util_vma_hole *high_hole = calloc(1, sizeof(*hole));
149 /* Adjust the hole to be the amount of space left at he bottom of the
150 * original hole.
152 hole->size = offset - hole->offset;
154 /* Place the new hole before the old hole so that the list is in order
157 list_addtail(&high_hole->link, &hole->link);
189 util_vma_foreach_hole(hole, heap) {
190 if (hole->offset <= offset) {
191 low_hole = hole;
194 high_hole = hole;
213 /* Merge into the low hole */
216 /* Merge into the high hole */
220 /* Neither hole is adjacent; make a new one */
221 struct util_vma_hole *hole = calloc(1, sizeof(*hole));
223 hole->offset = offset;
224 hole->size = size;
226 /* Add it after the high hole so we maintain high-to-low ordering */
228 list_add(&hole->link, &high_hole->link);
230 list_add(&hole->link, &heap->holes);