From 8873c7e494018637449a17a7f7ddaf88ad43f3c6 Mon Sep 17 00:00:00 2001 From: Mikael Kanstrup Date: Thu, 24 Aug 2017 16:16:34 +0200 Subject: iface_lists: Access all_ifaces member by reference Change access of all_ifaces elements from by val to by reference. With this change unnecessary copying of the whole struct is avoided but even more important is that elements no longer have to be removed and inserted whenever data is updated. This change aims to make it more clear that all_ifaces elements shall never be removed from the array without freeing resources via the capture_opts_free_interface_t function. NOTE: Code for GTK UI not updated Ping-Bug: 13864 Change-Id: I36742cb1d5c8daa136c9d3732a044a7c8e5c7fe7 Reviewed-on: https://code.wireshark.org/review/23201 Petri-Dish: Anders Broman Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu Reviewed-by: Anders Broman --- summary.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'summary.c') diff --git a/summary.c b/summary.c index ee0cbb3e2f..0fd6b8d6ba 100644 --- a/summary.c +++ b/summary.c @@ -203,7 +203,7 @@ void summary_fill_in_capture(capture_file *cf,capture_options *capture_opts, summary_tally *st) { iface_options iface; - interface_t device; + interface_t *device; guint i; if (st->ifaces->len == 0) { @@ -211,17 +211,17 @@ summary_fill_in_capture(capture_file *cf,capture_options *capture_opts, summary_ * XXX - do this only if we have a live capture. */ for (i = 0; i < capture_opts->all_ifaces->len; i++) { - device = g_array_index(capture_opts->all_ifaces, interface_t, i); - if (!device.selected) { + device = &g_array_index(capture_opts->all_ifaces, interface_t, i); + if (!device->selected) { continue; } - iface.cfilter = g_strdup(device.cfilter); - iface.name = g_strdup(device.name); - iface.descr = g_strdup(device.display_name); + iface.cfilter = g_strdup(device->cfilter); + iface.name = g_strdup(device->name); + iface.descr = g_strdup(device->display_name); iface.drops_known = cf->drops_known; iface.drops = cf->drops; - iface.snap = device.snaplen; - iface.encap_type = wtap_pcap_encap_to_wtap_encap(device.active_dlt); + iface.snap = device->snaplen; + iface.encap_type = wtap_pcap_encap_to_wtap_encap(device->active_dlt); g_array_append_val(st->ifaces, iface); } } -- cgit v1.2.3