diff options
author | Dario Lombardo <lomato@gmail.com> | 2016-04-21 10:14:11 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-04-22 21:26:13 +0000 |
commit | 13dc91f5b6b4c44e8a3056e6923f3435ce7c286a (patch) | |
tree | 6ea4b0d564e4700c8f663245bff9957703ada0d8 | |
parent | bbd8a4b94a481504b18e216089e1d3524323df8d (diff) |
addr_resolv: change g_slist to wmem_list.
Change-Id: Ifde09174e50bc2a9d695ac0a823e63f645284a10
Reviewed-on: https://code.wireshark.org/review/15050
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
-rw-r--r-- | epan/addr_resolv.c | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index ebd81ce446..f38e593ae9 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -205,8 +205,8 @@ static GHashTable *ipv4_hash_table = NULL; static GHashTable *ipv6_hash_table = NULL; static GHashTable *vlan_hash_table = NULL; -static GSList *manually_resolved_ipv4_list = NULL; -static GSList *manually_resolved_ipv6_list = NULL; +static wmem_list_t *manually_resolved_ipv4_list = NULL; +static wmem_list_t *manually_resolved_ipv6_list = NULL; typedef struct _resolved_ipv4 { @@ -344,7 +344,7 @@ ares_channel ghbn_chan; /* ares_gethostbyname -- Usually interactive, timeout */ static gboolean async_dns_initialized = FALSE; static guint async_dns_in_flight = 0; -static GList *async_dns_queue_head = NULL; +static wmem_list_t *async_dns_queue_head = NULL; /* push a dns request */ static void @@ -355,7 +355,7 @@ add_async_dns_ipv4(int type, guint32 addr) msg = wmem_new(wmem_epan_scope(), async_dns_queue_msg_t); msg->family = type; msg->addr.ip4 = addr; - async_dns_queue_head = g_list_append(async_dns_queue_head, (gpointer) msg); + wmem_list_append(async_dns_queue_head, (gpointer) msg); } #endif /* HAVE_C_ARES */ @@ -874,7 +874,7 @@ host_lookup6(const struct e_in6_addr *addr) caqm = wmem_new(wmem_epan_scope(), async_dns_queue_msg_t); caqm->family = AF_INET6; memcpy(&caqm->addr.ip6, addr, sizeof(caqm->addr.ip6)); - async_dns_queue_head = g_list_append(async_dns_queue_head, (gpointer) caqm); + wmem_list_append(async_dns_queue_head, (gpointer) caqm); } #endif } @@ -2102,12 +2102,12 @@ add_ip_name_from_string (const char *addr, const char *name) resolved_ipv6_entry = wmem_new(wmem_epan_scope(), resolved_ipv6_t); memcpy(&(resolved_ipv6_entry->ip6_addr), &host_addr.ip6_addr, 16); g_strlcpy(resolved_ipv6_entry->name, name, MAXNAMELEN); - manually_resolved_ipv6_list = g_slist_prepend(manually_resolved_ipv6_list, resolved_ipv6_entry); + wmem_list_prepend(manually_resolved_ipv6_list, resolved_ipv6_entry); } else { resolved_ipv4_entry = wmem_new(wmem_epan_scope(), resolved_ipv4_t); resolved_ipv4_entry->host_addr = host_addr.ip4_addr; g_strlcpy(resolved_ipv4_entry->name, name, MAXNAMELEN); - manually_resolved_ipv4_list = g_slist_prepend(manually_resolved_ipv4_list, resolved_ipv4_entry); + wmem_list_prepend(manually_resolved_ipv4_list, resolved_ipv4_entry); } return TRUE; @@ -2123,7 +2123,7 @@ ipv4_hash_table_resolved_to_list(gpointer key _U_, gpointer value, gpointer user hashipv4_t *ipv4_hash_table_entry = (hashipv4_t *)value; if ((ipv4_hash_table_entry->flags & USED_AND_RESOLVED_MASK) == RESOLVED_ADDRESS_USED) { - lists->ipv4_addr_list = g_list_prepend (lists->ipv4_addr_list, ipv4_hash_table_entry); + lists->ipv4_addr_list = g_list_prepend(lists->ipv4_addr_list, ipv4_hash_table_entry); } } @@ -2451,6 +2451,7 @@ host_name_lookup_process(void) { int nfds; fd_set rfds, wfds; gboolean nro = new_resolved_objects; + wmem_list_frame_t* head; new_resolved_objects = FALSE; @@ -2458,11 +2459,11 @@ host_name_lookup_process(void) { /* c-ares not initialized. Bail out and cancel timers. */ return nro; - async_dns_queue_head = g_list_first(async_dns_queue_head); + head = wmem_list_head(async_dns_queue_head); - while (async_dns_queue_head != NULL && async_dns_in_flight <= name_resolve_concurrency) { - caqm = (async_dns_queue_msg_t *) async_dns_queue_head->data; - async_dns_queue_head = g_list_remove(async_dns_queue_head, (void *) caqm); + while (head != NULL && async_dns_in_flight <= name_resolve_concurrency) { + caqm = (async_dns_queue_msg_t *)wmem_list_frame_data(head); + wmem_list_remove_frame(async_dns_queue_head, head); if (caqm->family == AF_INET) { ares_gethostbyaddr(ghba_chan, &caqm->addr.ip4, sizeof(guint32), AF_INET, c_ares_ghba_cb, caqm); @@ -2491,15 +2492,6 @@ host_name_lookup_process(void) { static void _host_name_lookup_cleanup(void) { - GList *cur; - - cur = g_list_first(async_dns_queue_head); - while (cur) { - g_free(cur->data); - cur = g_list_next (cur); - } - - g_list_free(async_dns_queue_head); async_dns_queue_head = NULL; if (async_dns_initialized) { @@ -2639,11 +2631,11 @@ static void add_manually_resolved(void) { if (manually_resolved_ipv4_list) { - g_slist_foreach(manually_resolved_ipv4_list, add_manually_resolved_ipv4, NULL); + wmem_list_foreach(manually_resolved_ipv4_list, add_manually_resolved_ipv4, NULL); } if (manually_resolved_ipv6_list) { - g_slist_foreach(manually_resolved_ipv6_list, add_manually_resolved_ipv6, NULL); + wmem_list_foreach(manually_resolved_ipv6_list, add_manually_resolved_ipv6, NULL); } } @@ -2662,6 +2654,15 @@ host_name_lookup_init(void) g_assert(ipv6_hash_table == NULL); ipv6_hash_table = g_hash_table_new(ipv6_oat_hash, ipv6_equal); + g_assert(async_dns_queue_head == NULL); + async_dns_queue_head = wmem_list_new(wmem_epan_scope()); + + g_assert(manually_resolved_ipv4_list == NULL); + manually_resolved_ipv4_list = wmem_list_new(wmem_epan_scope()); + + g_assert(manually_resolved_ipv6_list == NULL); + manually_resolved_ipv6_list = wmem_list_new(wmem_epan_scope()); + /* * Load the global hosts file, if we have one. */ @@ -2762,14 +2763,12 @@ void manually_resolve_cleanup(void) { if (manually_resolved_ipv4_list) { - g_slist_foreach(manually_resolved_ipv4_list, free_manually_resolved_ipv4, NULL); - g_slist_free(manually_resolved_ipv4_list); + wmem_list_foreach(manually_resolved_ipv4_list, free_manually_resolved_ipv4, NULL); manually_resolved_ipv4_list = NULL; } if (manually_resolved_ipv6_list) { - g_slist_foreach(manually_resolved_ipv6_list, free_manually_resolved_ipv6, NULL); - g_slist_free(manually_resolved_ipv6_list); + wmem_list_foreach(manually_resolved_ipv6_list, free_manually_resolved_ipv6, NULL); manually_resolved_ipv6_list = NULL; } |