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)
}
}
-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)
{
{
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;
}