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
|
@ -40,6 +40,7 @@ char *grub_net_default_server;
|
|||
struct grub_net_route
|
||||
{
|
||||
struct grub_net_route *next;
|
||||
struct grub_net_route **prev;
|
||||
grub_net_network_level_netaddress_t target;
|
||||
char *name;
|
||||
struct grub_net_network_level_protocol *prot;
|
||||
|
@ -206,8 +207,7 @@ grub_net_card_unregister (struct grub_net_card *card)
|
|||
card->driver->close (card);
|
||||
card->opened = 0;
|
||||
}
|
||||
grub_list_remove (GRUB_AS_LIST_P (&grub_net_cards),
|
||||
GRUB_AS_LIST (card));
|
||||
grub_list_remove (GRUB_AS_LIST (card));
|
||||
}
|
||||
|
||||
static struct grub_net_slaac_mac_list *
|
||||
|
@ -366,8 +366,7 @@ grub_net_route_register (struct grub_net_route *route)
|
|||
static inline void
|
||||
grub_net_route_unregister (struct grub_net_route *route)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST_P (&grub_net_routes),
|
||||
GRUB_AS_LIST (route));
|
||||
grub_list_remove (GRUB_AS_LIST (route));
|
||||
}
|
||||
|
||||
#define FOR_NET_ROUTES(var) for (var = grub_net_routes; var; var = var->next)
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
struct unacked
|
||||
{
|
||||
struct unacked *next;
|
||||
struct unacked **prev;
|
||||
struct grub_net_buff *nb;
|
||||
grub_uint64_t last_try;
|
||||
int try_count;
|
||||
|
@ -49,6 +50,7 @@ enum
|
|||
struct grub_net_tcp_socket
|
||||
{
|
||||
struct grub_net_tcp_socket *next;
|
||||
struct grub_net_tcp_socket **prev;
|
||||
|
||||
int established;
|
||||
int i_closed;
|
||||
|
@ -80,6 +82,7 @@ struct grub_net_tcp_socket
|
|||
struct grub_net_tcp_listen
|
||||
{
|
||||
struct grub_net_tcp_listen *next;
|
||||
struct grub_net_tcp_listen **prev;
|
||||
|
||||
grub_uint16_t port;
|
||||
const struct grub_net_network_level_interface *inf;
|
||||
|
@ -149,8 +152,7 @@ grub_net_tcp_listen (grub_uint16_t port,
|
|||
void
|
||||
grub_net_tcp_stop_listen (grub_net_tcp_listen_t listen)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST_P (&tcp_listens),
|
||||
GRUB_AS_LIST (listen));
|
||||
grub_list_remove (GRUB_AS_LIST (listen));
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -640,8 +642,7 @@ grub_net_tcp_open (char *server,
|
|||
GRUB_NET_IP_TCP);
|
||||
if (err)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST_P (&tcp_sockets),
|
||||
GRUB_AS_LIST (socket));
|
||||
grub_list_remove (GRUB_AS_LIST (socket));
|
||||
grub_free (socket);
|
||||
grub_netbuff_free (nb);
|
||||
return NULL;
|
||||
|
@ -654,8 +655,7 @@ grub_net_tcp_open (char *server,
|
|||
}
|
||||
if (!socket->established)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST_P (&tcp_sockets),
|
||||
GRUB_AS_LIST (socket));
|
||||
grub_list_remove (GRUB_AS_LIST (socket));
|
||||
if (socket->they_reseted)
|
||||
grub_error (GRUB_ERR_NET_PORT_CLOSED, "port closed");
|
||||
else
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
struct grub_net_udp_socket
|
||||
{
|
||||
struct grub_net_udp_socket *next;
|
||||
struct grub_net_udp_socket **prev;
|
||||
|
||||
enum { GRUB_NET_SOCKET_START,
|
||||
GRUB_NET_SOCKET_ESTABLISHED,
|
||||
|
@ -53,8 +54,7 @@ udp_socket_register (grub_net_udp_socket_t sock)
|
|||
void
|
||||
grub_net_udp_close (grub_net_udp_socket_t sock)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST_P (&udp_sockets),
|
||||
GRUB_AS_LIST (sock));
|
||||
grub_list_remove (GRUB_AS_LIST (sock));
|
||||
grub_free (sock);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue