respondd: append interface infos at the head of the list

This avoids walking to the end.
This commit is contained in:
lemoer 2016-12-01 01:06:44 +01:00
parent 2c302aa012
commit 9198ad056d
1 changed files with 8 additions and 7 deletions

View File

@ -621,13 +621,14 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
struct interface_delay_info **pos = &if_delay_info_list;
// walk to the end of the list
for(; *pos; pos = &((*pos)->next)) {}
*pos = malloc(sizeof(*if_delay_info_list));
(*pos)->ifindex = last_ifindex;
(*pos)->max_multicast_delay = max_multicast_delay;
(*pos)->next = NULL;
// insert the interface delay info at the beginning of the list
struct interface_delay_info **head = &if_delay_info_list;
struct interface_delay_info *old_head = if_delay_info_list;
*head = malloc(sizeof(*if_delay_info_list));
(*head)->ifindex = last_ifindex;
(*head)->max_multicast_delay = max_multicast_delay;
(*head)->next = old_head;
break;