aboutsummaryrefslogtreecommitdiffstats
path: root/capture_opts.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2007-08-22 16:30:16 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2007-08-22 16:30:16 +0000
commit2f77efce7da0a079c38609e7bd24cc69937863b1 (patch)
tree2c5d954d066dd1bc7b7b81af5e15b2ebea283dcd /capture_opts.c
parent914e885354a310ae9219a9cd42da5f1123a3acc3 (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. svn path=/trunk/; revision=22587
Diffstat (limited to 'capture_opts.c')
-rw-r--r--capture_opts.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/capture_opts.c b/capture_opts.c
index c3ecd6a20a..df2c8063b5 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -86,6 +86,7 @@ capture_opts_init(capture_options *capture_opts, void *cfile)
capture_opts->cf = cfile;
capture_opts->cfilter = g_strdup(""); /* No capture filter string specified */
capture_opts->iface = NULL; /* Default is "pick the first interface" */
+ capture_opts->iface_descr = NULL;
#ifdef _WIN32
capture_opts->buffer_size = 1; /* 1 MB */
#endif
@@ -133,6 +134,7 @@ capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_optio
g_log(log_domain, log_level, "CFile : 0x%p", capture_opts->cf);
g_log(log_domain, log_level, "Filter : %s", capture_opts->cfilter);
g_log(log_domain, log_level, "Interface : %s", capture_opts->iface);
+ g_log(log_domain, log_level, "Interface Descr : %s", capture_opts->iface_descr);
#ifdef _WIN32
g_log(log_domain, log_level, "BufferSize : %u (MB)", capture_opts->buffer_size);
#endif
@@ -317,6 +319,10 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg)
return 1;
}
capture_opts->iface = g_strdup(if_info->name);
+ /* We don't set iface_descr here because doing so requires
+ * capture_ui_utils.c which requires epan/prefs.c which is
+ * probably a bit too much dependency for here...
+ */
free_interface_list(if_list);
} else {
capture_opts->iface = g_strdup(optarg);
@@ -686,6 +692,10 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
if (capture_device != NULL) {
/* Yes - use it. */
capture_opts->iface = g_strdup(capture_device);
+ /* We don't set iface_descr here because doing so requires
+ * capture_ui_utils.c which requires epan/prefs.c which is
+ * probably a bit too much dependency for here...
+ */
} else {
/* No - pick the first one from the list of interfaces. */
if_list = get_interface_list(&err, &err_str);
@@ -705,6 +715,10 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
}
if_info = if_list->data; /* first interface */
capture_opts->iface = g_strdup(if_info->name);
+ /* We don't set iface_descr here because doing so requires
+ * capture_ui_utils.c which requires epan/prefs.c which is
+ * probably a bit too much dependency for here...
+ */
free_interface_list(if_list);
}
}