aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authormorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>2007-08-22 16:30:16 +0000
committermorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>2007-08-22 16:30:16 +0000
commit94d4a3a89ddc2982d28b43465e0e85da638f8ff9 (patch)
tree2c5d954d066dd1bc7b7b81af5e15b2ebea283dcd /gtk
parent7e467dcdec10219e01ddc7e0806b9b190bc4d9e8 (diff)
Fix bug http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1757 :
Try to call get_interface_descriptive_name() as little as possible (storing the result in capture_opts) to avoid a performance hit during live capture (especially if you have lots of interfaces) and to avoid leaking memory. One issue with this is that capture_opts.c cannot (without adding significant dependencies) set the iface_descr so readers of that field (only gtk/main.c and tshark.c) use a macro to (set if not already set and) get the value of that field. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@22587 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk')
-rw-r--r--gtk/capture_dlg.c8
-rw-r--r--gtk/capture_if_dlg.c7
-rw-r--r--gtk/main.c60
3 files changed, 47 insertions, 28 deletions
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index 66fa565384..b7f9bae0f1 100644
--- a/gtk/capture_dlg.c
+++ b/gtk/capture_dlg.c
@@ -696,6 +696,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
make the one from the preferences file the default */
if_device = g_strdup(prefs.capture_device);
capture_opts->iface = g_strdup(get_if_name(if_device));
+ capture_opts->iface_descr = get_interface_descriptive_name(capture_opts->iface);
g_free(if_device);
}
@@ -1316,7 +1317,8 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
/* everythings prepared, now it's really time to start the capture */
void
-capture_start_confirmed(void) {
+capture_start_confirmed(void)
+{
/* init iface, if never used before */
@@ -1338,6 +1340,7 @@ capture_start_confirmed(void) {
if_device = g_strdup(prefs.capture_device);
if_name = get_if_name(if_device);
capture_opts->iface = g_strdup(if_name);
+ capture_opts->iface_descr = get_interface_descriptive_name(capture_opts->iface);
g_free(if_device);
}
@@ -1516,7 +1519,10 @@ capture_dlg_prep(gpointer parent_w) {
}
if (capture_opts->iface)
g_free(capture_opts->iface);
+ if (capture_opts->iface_descr)
+ g_free(capture_opts->iface_descr);
capture_opts->iface = g_strdup(if_name);
+ capture_opts->iface_descr = get_interface_descriptive_name(capture_opts->iface);
g_free(entry_text);
/* The Linktype will be stored when the interface will be changed, or if not, not datalink option is used,
the acquisition will be performed on the default datalink for the device */
diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c
index 959d4d2615..fcbb94466c 100644
--- a/gtk/capture_if_dlg.c
+++ b/gtk/capture_if_dlg.c
@@ -48,6 +48,7 @@
#include "capture_dlg.h"
#include "capture_if_details_dlg.h"
#include "capture_errs.h"
+#include "capture_ui_utils.h"
#include "recent.h"
#include <epan/prefs.h>
@@ -136,8 +137,11 @@ capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
if (capture_opts->iface)
g_free(capture_opts->iface);
+ if (capture_opts->iface_descr)
+ g_free(capture_opts->iface_descr);
capture_opts->iface = g_strdup(if_dlg_data->device);
+ capture_opts->iface_descr = get_interface_descriptive_name(capture_opts->iface);
/* XXX - remove this? */
if (capture_opts->save_file) {
@@ -160,8 +164,11 @@ capture_prepare_cb(GtkWidget *prepare_bt _U_, gpointer if_data)
if (capture_opts->iface)
g_free(capture_opts->iface);
+ if (capture_opts->iface_descr)
+ g_free(capture_opts->iface_descr);
capture_opts->iface = g_strdup(if_dlg_data->device);
+ capture_opts->iface_descr = get_interface_descriptive_name(capture_opts->iface);
/* stop capturing from all interfaces, we are going to do real work now ... */
window_destroy(cap_if_w);
diff --git a/gtk/main.c b/gtk/main.c
index 0c0ebbe4ee..61d3755b9a 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1608,7 +1608,7 @@ main_cf_cb_live_capture_prepared(capture_options *capture_opts)
if(capture_opts->iface) {
title = g_strdup_printf("%s: Capturing - Wireshark",
- get_interface_descriptive_name(capture_opts->iface));
+ GET_IFACE_DESCR(capture_opts));
} else {
title = g_strdup_printf("Capturing - Wireshark");
}
@@ -1643,7 +1643,7 @@ main_cf_cb_live_capture_update_started(capture_options *capture_opts)
switching to the next multiple file. */
if(capture_opts->iface) {
title = g_strdup_printf("%s: Capturing - Wireshark",
- get_interface_descriptive_name(capture_opts->iface));
+ GET_IFACE_DESCR(capture_opts));
} else {
title = g_strdup_printf("Capturing - Wireshark");
}
@@ -1660,8 +1660,8 @@ main_cf_cb_live_capture_update_started(capture_options *capture_opts)
if(capture_opts->iface) {
capture_msg = g_strdup_printf(" %s: <live capture in progress> to file: %s",
- get_interface_descriptive_name(capture_opts->iface),
- (capture_opts->save_file) ? capture_opts->save_file : "");
+ GET_IFACE_DESCR(capture_opts),
+ (capture_opts->save_file) ? capture_opts->save_file : "");
} else {
capture_msg = g_strdup_printf(" <live capture in progress> to file: %s",
(capture_opts->save_file) ? capture_opts->save_file : "");
@@ -1687,39 +1687,45 @@ main_cf_cb_live_capture_update_continue(capture_file *cf)
/* XXX - don't show the highest expert level unless the TCP checksum offloading is "solved" */
if (cf->f_datalen/1024/1024 > 10) {
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %lld MB [Expert: %s]",
- get_interface_descriptive_name(capture_opts->iface),
- capture_opts->save_file,
- cf->f_datalen/1024/1024,
- val_to_str(expert_get_highest_severity(), expert_severity_vals, "Unknown (%u)"));
+ GET_IFACE_DESCR(capture_opts),
+ capture_opts->save_file,
+ cf->f_datalen/1024/1024,
+ val_to_str(expert_get_highest_severity(),
+ expert_severity_vals,
+ "Unknown (%u)"));
} else if (cf->f_datalen/1024 > 10) {
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %lld KB [Expert: %s]",
- get_interface_descriptive_name(capture_opts->iface),
- capture_opts->save_file,
- cf->f_datalen/1024,
- val_to_str(expert_get_highest_severity(), expert_severity_vals, "Unknown (%u)"));
+ GET_IFACE_DESCR(capture_opts),
+ capture_opts->save_file,
+ cf->f_datalen/1024,
+ val_to_str(expert_get_highest_severity(),
+ expert_severity_vals,
+ "Unknown (%u)"));
} else {
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %lld Bytes [Expert: %s]",
- get_interface_descriptive_name(capture_opts->iface),
- capture_opts->save_file,
- cf->f_datalen,
- val_to_str(expert_get_highest_severity(), expert_severity_vals, "Unknown (%u)"));
+ GET_IFACE_DESCR(capture_opts),
+ capture_opts->save_file,
+ cf->f_datalen,
+ val_to_str(expert_get_highest_severity(),
+ expert_severity_vals,
+ "Unknown (%u)"));
}
#endif
if (cf->f_datalen/1024/1024 > 10) {
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %" G_GINT64_MODIFIER "d MB",
- get_interface_descriptive_name(capture_opts->iface),
- capture_opts->save_file,
- cf->f_datalen/1024/1024);
+ GET_IFACE_DESCR(capture_opts),
+ capture_opts->save_file,
+ cf->f_datalen/1024/1024);
} else if (cf->f_datalen/1024 > 10) {
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %" G_GINT64_MODIFIER "d KB",
- get_interface_descriptive_name(capture_opts->iface),
- capture_opts->save_file,
- cf->f_datalen/1024);
+ GET_IFACE_DESCR(capture_opts),
+ capture_opts->save_file,
+ cf->f_datalen/1024);
} else {
capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %" G_GINT64_MODIFIER "d Bytes",
- get_interface_descriptive_name(capture_opts->iface),
- capture_opts->save_file,
- cf->f_datalen);
+ GET_IFACE_DESCR(capture_opts),
+ capture_opts->save_file,
+ cf->f_datalen);
}
statusbar_push_file_msg(capture_msg);
@@ -1782,8 +1788,8 @@ main_cf_cb_live_capture_fixed_started(capture_options *capture_opts)
statusbar_pop_file_msg();
capture_msg = g_strdup_printf(" %s: <live capture in progress> to file: %s",
- get_interface_descriptive_name(capture_opts->iface),
- (capture_opts->save_file) ? capture_opts->save_file : "");
+ GET_IFACE_DESCR(capture_opts),
+ (capture_opts->save_file) ? capture_opts->save_file : "");
statusbar_push_file_msg(capture_msg);
gtk_statusbar_push(GTK_STATUSBAR(packets_bar), packets_ctx, " P: 0");