Replace single-linked with double-linked lists. It results in more
compact and more efficient code. * grub-core/kern/list.c (grub_list_push): Moved from here ... * include/grub/list.h (grub_list_push): ... to here. Set prev. (grub_list_remove): Moved from here ... * include/grub/list.h (grub_list_remove): ... here. Use and set prev. (grub_prio_list_insert): Set prev. * include/grub/list.h (grub_list): Add prev. All users updated.
This commit is contained in:
parent
48b391e9ab
commit
87edb8940a
27 changed files with 111 additions and 75 deletions
|
@ -31,6 +31,7 @@ struct grub_term_autoload *grub_term_output_autoload = NULL;
|
|||
struct abstract_terminal
|
||||
{
|
||||
struct abstract_terminal *next;
|
||||
struct abstract_terminal *prev;
|
||||
const char *name;
|
||||
grub_err_t (*init) (struct abstract_terminal *term);
|
||||
grub_err_t (*fini) (struct abstract_terminal *term);
|
||||
|
@ -137,7 +138,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
|||
if (term->init && term->init (term) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +157,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
|||
if (!term->next && term == *enabled)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"can't remove the last terminal");
|
||||
grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST (term));
|
||||
if (term->fini)
|
||||
term->fini (term);
|
||||
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||
|
@ -174,7 +175,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
|||
if (term->init && term->init (term) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +193,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
|||
if (!term->next && term == *enabled)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"can't remove the last terminal");
|
||||
grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST (term));
|
||||
if (term->fini)
|
||||
term->fini (term);
|
||||
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||
|
@ -208,6 +209,7 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
|||
int argc, char **args)
|
||||
{
|
||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, next);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, prev);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, name);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, init);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, fini);
|
||||
|
@ -224,6 +226,7 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
|
|||
int argc, char **args)
|
||||
{
|
||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, next);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, prev);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, name);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, init);
|
||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, fini);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue