From c3b25e8111dc304486537d7cc60e54ba27c04fa0 Mon Sep 17 00:00:00 2001 From: AndersBroman Date: Wed, 28 Sep 2016 13:31:14 +0200 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- caputils/capture-pcap-util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'caputils/capture-pcap-util.c') 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 -- cgit v1.2.1