Eradicate grub_list_insert

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-26 20:00:06 +01:00
parent fda282327f
commit 82f542016e
2 changed files with 14 additions and 27 deletions

View file

@ -36,8 +36,6 @@ typedef int (*grub_list_test_t) (grub_list_t new_item, grub_list_t item);
void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item);
void * EXPORT_FUNC(grub_list_pop) (grub_list_t *head);
void EXPORT_FUNC(grub_list_remove) (grub_list_t *head, grub_list_t item);
void EXPORT_FUNC(grub_list_insert) (grub_list_t *head, grub_list_t item,
grub_list_test_t test);
#define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next)

View file

@ -53,20 +53,6 @@ grub_list_remove (grub_list_t *head, grub_list_t item)
}
}
void
grub_list_insert (grub_list_t *head, grub_list_t item,
grub_list_test_t test)
{
grub_list_t *p, q;
for (p = head, q = *p; q; p = &(q->next), q = q->next)
if (test (item, q))
break;
*p = item;
item->next = q;
}
void *
grub_named_list_find (grub_named_list_t head, const char *name)
{
@ -84,27 +70,30 @@ grub_prio_list_insert (grub_prio_list_t *head, grub_prio_list_t nitem)
{
int inactive = 0;
auto int test (grub_prio_list_t new_item, grub_prio_list_t item);
int test (grub_prio_list_t new_item, grub_prio_list_t item)
grub_prio_list_t *p, q;
for (p = head, q = *p; q; p = &(q->next), q = q->next)
{
int r;
r = grub_strcmp (new_item->name, item->name);
if (r)
return (r < 0);
r = grub_strcmp (nitem->name, q->name);
if (r < 0)
break;
if (r > 0)
continue;
if (new_item->prio >= (item->prio & GRUB_PRIO_LIST_PRIO_MASK))
if (nitem->prio >= (q->prio & GRUB_PRIO_LIST_PRIO_MASK))
{
item->prio &= ~GRUB_PRIO_LIST_FLAG_ACTIVE;
return 1;
q->prio &= ~GRUB_PRIO_LIST_FLAG_ACTIVE;
break;
}
inactive = 1;
return 0;
}
grub_list_insert (GRUB_AS_LIST_P (head), GRUB_AS_LIST (nitem),
(grub_list_test_t) test);
*p = nitem;
nitem->next = q;
if (! inactive)
nitem->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
}