summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2009-02-09 07:10:46 +0000
committerJaap Keuter <jaap.keuter@xs4all.nl>2009-02-09 07:10:46 +0000
commitacdf91e263a438e5914da24bce4d57f2f67f2a9a (patch)
treeccd9ee0a3d59ae9e64f5552b607365304675b4b5 /file.c
parenta04a5d70e6fd85ca96567d8de76ba1944534c452 (diff)
downloadwireshark-acdf91e263a438e5914da24bce4d57f2f67f2a9a.tar.gz
Make "Copy as Filter" on the packet list actually work.
Up till now every packet in the packet list got a copy of the pointer to the filter expressions for the last packets' columns. Hence any 'Copy as Filter" on a column got the expression of the last packet in the packet list. Instead every packet needs to get a pointer to the filter expressions for its own columns. This requires making a copy of the filter expressions themselves. Since this is a bug in 1.0 as well the GLIB1 code is provided for backporting, which can later be dropped from the development tree. svn path=/trunk/; revision=27396
Diffstat (limited to 'file.c')
-rw-r--r--file.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/file.c b/file.c
index f045053fc3..ca4e22911b 100644
--- a/file.c
+++ b/file.c
@@ -333,6 +333,12 @@ cf_reset_state(capture_file *cf)
cf->user_saved = FALSE;
if (cf->plist_chunk != NULL) {
+ frame_data *fdata = cf->plist;
+ while (fdata) {
+ g_strfreev(fdata->col_expr.col_expr);
+ g_strfreev(fdata->col_expr.col_expr_val);
+ fdata = fdata->next;
+ }
g_mem_chunk_destroy(cf->plist_chunk);
cf->plist_chunk = NULL;
}
@@ -1034,9 +1040,26 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
/* This is the last frame we've seen so far. */
cf->last_displayed = fdata;
- fdata->col_expr.col_expr = cf->cinfo.col_expr.col_expr;
- fdata->col_expr.col_expr_val = cf->cinfo.col_expr.col_expr_val;
+ /* XXX - GLIB1 implementation provided to support backport of this feature. */
+#if (GLIB_MAJOR_VERSION >= 2)
+ fdata->col_expr.col_expr = g_strdupv(cf->cinfo.col_expr.col_expr);
+ fdata->col_expr.col_expr_val = g_strdupv(cf->cinfo.col_expr.col_expr_val);
+#else
+ {
+ gint i;
+
+ fdata->col_expr.col_expr = (gchar **) g_malloc(sizeof(gchar *) * (cf->cinfo.num_cols + 1));
+ fdata->col_expr.col_expr_val = (gchar **) g_malloc(sizeof(gchar *) * (cf->cinfo.num_cols + 1));
+ for (i=0; i <= cf->cinfo.num_cols; i++)
+ {
+ fdata->col_expr.col_expr[i] = g_strdup(cf->cinfo.col_expr.col_expr[i]);
+ fdata->col_expr.col_expr_val[i] = g_strdup(cf->cinfo.col_expr.col_expr_val[i]);
+ }
+ fdata->col_expr.col_expr[i] = NULL;
+ fdata->col_expr.col_expr_val[i] = NULL;
+ }
+#endif
row = packet_list_append(cf->cinfo.col_data, fdata);
/* colorize packet: first apply color filters
@@ -1093,6 +1116,8 @@ read_packet(capture_file *cf, dfilter_t *dfcode, gint64 offset)
fdata->flags.marked = 0;
fdata->flags.ref_time = 0;
fdata->color_filter = NULL;
+ fdata->col_expr.col_expr = NULL;
+ fdata->col_expr.col_expr_val = NULL;
fdata->abs_ts.secs = phdr->ts.secs;
fdata->abs_ts.nsecs = phdr->ts.nsecs;
@@ -1134,6 +1159,8 @@ read_packet(capture_file *cf, dfilter_t *dfcode, gint64 offset)
...but, at least in one test I did, where I just made the chunk
a G_ALLOC_ONLY chunk and read in a huge capture file, it didn't
seem to save a noticeable amount of time or space. */
+ g_strfreev(fdata->col_expr.col_expr);
+ g_strfreev(fdata->col_expr.col_expr_val);
g_mem_chunk_free(cf->plist_chunk, fdata);
}