util/range_remap: use child memory context for list
This will allow us to easily free the list when we switch to a sorted array in a following patch Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37754>
This commit is contained in:
committed by
Marge Bot
parent
9536de6eac
commit
f8326657f8
@@ -95,7 +95,7 @@ util_range_insert_remap(unsigned start, unsigned end,
|
||||
struct list_head *r_list = &r_remap->r_list;
|
||||
struct list_range_entry *lre = NULL;
|
||||
if (list_is_empty(r_list)) {
|
||||
lre = rzalloc(r_list, struct list_range_entry);
|
||||
lre = rzalloc(r_remap->list_mem_ctx, struct list_range_entry);
|
||||
list_addtail(&lre->node, r_list);
|
||||
goto insert_end;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ util_range_insert_remap(unsigned start, unsigned end,
|
||||
struct list_range_entry *last_entry =
|
||||
list_last_entry(r_list, struct list_range_entry, node);
|
||||
if (last_entry->entry.end < start) {
|
||||
lre = rzalloc(r_list, struct list_range_entry);
|
||||
lre = rzalloc(r_remap->list_mem_ctx, struct list_range_entry);
|
||||
list_addtail(&lre->node, r_list);
|
||||
goto insert_end;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ util_range_insert_remap(unsigned start, unsigned end,
|
||||
while (low <= high) {
|
||||
if (end < mid_entry->entry.start) {
|
||||
if (low == high || mid == low) {
|
||||
lre = rzalloc(r_list, struct list_range_entry);
|
||||
lre = rzalloc(r_remap->list_mem_ctx, struct list_range_entry);
|
||||
list_addtail(&lre->node, &mid_entry->node); /* insert before mid */
|
||||
goto insert_end;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ util_range_insert_remap(unsigned start, unsigned end,
|
||||
}
|
||||
} else if (start > mid_entry->entry.end) {
|
||||
if (low == high || mid == high) {
|
||||
lre = rzalloc(r_list, struct list_range_entry);
|
||||
lre = rzalloc(r_remap->list_mem_ctx, struct list_range_entry);
|
||||
list_add(&lre->node, &mid_entry->node); /* insert after mid */
|
||||
goto insert_end;
|
||||
}
|
||||
@@ -183,6 +183,7 @@ util_create_range_remap()
|
||||
{
|
||||
struct range_remap *r = rzalloc(NULL, struct range_remap);
|
||||
list_inithead(&r->r_list);
|
||||
r->list_mem_ctx = ralloc_context(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ extern "C" {
|
||||
struct range_remap {
|
||||
/* Linked list of range remap entries */
|
||||
struct list_head r_list;
|
||||
|
||||
void *list_mem_ctx;
|
||||
};
|
||||
|
||||
struct range_entry {
|
||||
|
||||
Reference in New Issue
Block a user