diff options
author | AndersBroman <anders.broman@ericsson.com> | 2016-09-28 13:31:14 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-09-28 13:43:40 +0000 |
commit | c3b25e8111dc304486537d7cc60e54ba27c04fa0 (patch) | |
tree | b8284df0f843ac05441373d60e027d94d3af1d09 /caputils | |
parent | 4f636d100e35865fc7156ffb2ba674605d1b404c (diff) |
Use g_slist_prepend, it should be faster if there's a lot of IP addresses
Change-Id: I3861c0af24523315db6889b22ec93159174ba86f
Reviewed-on: https://code.wireshark.org/review/17966
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'caputils')
-rw-r--r-- | caputils/capture-pcap-util-unix.c | 6 | ||||
-rw-r--r-- | caputils/capture-pcap-util.c | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/caputils/capture-pcap-util-unix.c b/caputils/capture-pcap-util-unix.c index 29be6d2b83..66a54c8591 100644 --- a/caputils/capture-pcap-util-unix.c +++ b/caputils/capture-pcap-util-unix.c @@ -211,6 +211,9 @@ get_interface_list(int *err, char **err_str) g_list_foreach(il, search_for_if_cb, &user_data); if (user_data.if_info != NULL) { if_info_add_address(user_data.if_info, &ifr->ifr_addr); + if (user_data.if_info->addrs) { + g_slist_reverse(user_data.if_info->addrs); + } goto next; } @@ -260,6 +263,9 @@ get_interface_list(int *err, char **err_str) strncmp(ifr->ifr_name, "lo", 2) == 0); if_info = if_info_new(ifr->ifr_name, NULL, loopback); if_info_add_address(if_info, &ifr->ifr_addr); + if (if_info->addrs) { + g_slist_reverse(if_info->addrs); + } if (loopback) il = g_list_append(il, if_info); else { diff --git a/caputils/capture-pcap-util.c b/caputils/capture-pcap-util.c index c014f83872..a41b7668d5 100644 --- a/caputils/capture-pcap-util.c +++ b/caputils/capture-pcap-util.c @@ -423,7 +423,7 @@ if_info_add_address(if_info_t *if_info, struct sockaddr *addr) if_addr->ifat_type = IF_AT_IPv4; if_addr->addr.ip4_addr = *((guint32 *)&(ai->sin_addr.s_addr)); - if_info->addrs = g_slist_append(if_info->addrs, if_addr); + if_info->addrs = g_slist_prepend(if_info->addrs, if_addr); break; case AF_INET6: @@ -433,7 +433,7 @@ if_info_add_address(if_info_t *if_info, struct sockaddr *addr) memcpy((void *)&if_addr->addr.ip6_addr, (void *)&ai6->sin6_addr.s6_addr, sizeof if_addr->addr.ip6_addr); - if_info->addrs = g_slist_append(if_info->addrs, if_addr); + if_info->addrs = g_slist_prepend(if_info->addrs, if_addr); break; } } @@ -452,6 +452,10 @@ if_info_ip(if_info_t *if_info, pcap_if_t *d) if (a->addr != NULL) if_info_add_address(if_info, a->addr); } + + if(if_info->addrs){ + if_info->addrs = g_slist_reverse(if_info->addrs); + } } #ifdef HAVE_PCAP_REMOTE |