Lines Matching full:node
25 static void mlist_delete(MemList *list, MemBlock *node) in mlist_delete() argument
27 g_assert(list && node); in mlist_delete()
28 QTAILQ_REMOVE(list, node, MLIST_ENTNAME); in mlist_delete()
29 g_free(node); in mlist_delete()
34 MemBlock *node; in mlist_find_key() local
35 QTAILQ_FOREACH(node, head, MLIST_ENTNAME) { in mlist_find_key()
36 if (node->addr == addr) { in mlist_find_key()
37 return node; in mlist_find_key()
45 MemBlock *node; in mlist_find_space() local
47 QTAILQ_FOREACH(node, head, MLIST_ENTNAME) { in mlist_find_space()
48 if (node->size >= size) { in mlist_find_space()
49 return node; in mlist_find_space()
57 MemBlock *node; in mlist_sort_insert() local
60 QTAILQ_FOREACH(node, head, MLIST_ENTNAME) { in mlist_sort_insert()
61 if (insr->addr < node->addr) { in mlist_sort_insert()
62 QTAILQ_INSERT_BEFORE(node, insr, MLIST_ENTNAME); in mlist_sort_insert()
71 static inline uint64_t mlist_boundary(MemBlock *node) in mlist_boundary() argument
73 return node->size + node->addr; in mlist_boundary()
85 static void mlist_coalesce(MemList *head, MemBlock *node) in mlist_coalesce() argument
87 g_assert(node); in mlist_coalesce()
94 left = QTAILQ_PREV(node, MLIST_ENTNAME); in mlist_coalesce()
95 right = QTAILQ_NEXT(node, MLIST_ENTNAME); in mlist_coalesce()
98 if (left && mlist_boundary(left) == node->addr) { in mlist_coalesce()
99 node = mlist_join(head, left, node); in mlist_coalesce()
104 if (right && mlist_boundary(node) == right->addr) { in mlist_coalesce()
105 node = mlist_join(head, node, right); in mlist_coalesce()
138 /* re-use this freenode as our used node */ in mlist_fulfill()
142 /* adjust the free node and create a new used node */ in mlist_fulfill()
156 MemBlock *node; in mlist_check() local
160 QTAILQ_FOREACH(node, s->free, MLIST_ENTNAME) { in mlist_check()
161 g_assert_cmpint(node->addr, >, addr); in mlist_check()
162 g_assert_cmpint(node->addr, >=, next); in mlist_check()
163 addr = node->addr; in mlist_check()
164 next = node->addr + node->size; in mlist_check()
169 QTAILQ_FOREACH(node, s->used, MLIST_ENTNAME) { in mlist_check()
170 g_assert_cmpint(node->addr, >, addr); in mlist_check()
171 g_assert_cmpint(node->addr, >=, next); in mlist_check()
172 addr = node->addr; in mlist_check()
173 next = node->addr + node->size; in mlist_check()
179 MemBlock *node; in mlist_alloc() local
181 node = mlist_find_space(s->free, size); in mlist_alloc()
182 if (!node) { in mlist_alloc()
186 return mlist_fulfill(s, node, size); in mlist_alloc()
191 MemBlock *node; in mlist_free() local
197 node = mlist_find_key(s->used, addr); in mlist_free()
198 if (!node) { in mlist_free()
206 QTAILQ_REMOVE(s->used, node, MLIST_ENTNAME); in mlist_free()
207 mlist_sort_insert(s->free, node); in mlist_free()
208 mlist_coalesce(s->free, node); in mlist_free()
217 MemBlock *node; in alloc_destroy() local
222 QTAILQ_FOREACH_SAFE(node, allocator->used, MLIST_ENTNAME, tmp) { in alloc_destroy()
226 node->addr, node->size); in alloc_destroy()
231 g_free(node); in alloc_destroy()
235 * should be only one node here with a specific address and size. */ in alloc_destroy()
237 QTAILQ_FOREACH_SAFE(node, allocator->free, MLIST_ENTNAME, tmp) { in alloc_destroy()
239 if ((node->addr != allocator->start) || in alloc_destroy()
240 (node->size != allocator->end - allocator->start)) { in alloc_destroy()
246 g_free(node); in alloc_destroy()
290 MemBlock *node; in alloc_init() local
301 node = mlist_new(s->start, s->end - s->start); in alloc_init()
302 QTAILQ_INSERT_HEAD(s->free, node, MLIST_ENTNAME); in alloc_init()
315 MemBlock *node, *tmp; in migrate_allocator() local
324 QTAILQ_FOREACH_SAFE(node, dst->used, MLIST_ENTNAME, tmp) { in migrate_allocator()
325 g_free(node); in migrate_allocator()
327 QTAILQ_FOREACH_SAFE(node, dst->free, MLIST_ENTNAME, tmp) { in migrate_allocator()
328 g_free(node); in migrate_allocator()
343 node = mlist_new(src->start, src->end - src->start); in migrate_allocator()
344 QTAILQ_INSERT_HEAD(src->free, node, MLIST_ENTNAME); in migrate_allocator()