diff options
author | jake <jake@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-02-09 07:10:46 +0000 |
---|---|---|
committer | jake <jake@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-02-09 07:10:46 +0000 |
commit | 5103abeac391f1a5da66938f99945fc34f76842b (patch) | |
tree | ccd9ee0a3d59ae9e64f5552b607365304675b4b5 /file.c | |
parent | 9d3987d4ba948519e65ed5564cc36f89a930184e (diff) |
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.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27396 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 31 |
1 files changed, 29 insertions, 2 deletions
@@ -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); } |