Track length of columns strings. We'll need this in order to resize columns quickly
authorkrj <krj@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 7 Sep 2009 11:33:38 +0000 (11:33 +0000)
committerkrj <krj@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 7 Sep 2009 11:33:38 +0000 (11:33 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29759 f5534014-38df-0310-8fa8-9805f1628bb7

epan/frame_data.h
file.c
gtk/packet_list_store.c

index 90b44f919c7cbae39efbd42e22e26fac19652f11..69b551b2e4c0655484f23af9f322a8bf13d9cf46 100644 (file)
@@ -59,6 +59,7 @@ typedef struct _frame_data {
   nstime_t     del_cap_ts;  /* Delta timestamp to previous captured frame (yes, it can be negative) */
   gint64       file_off;    /* File offset */
   gchar        **col_text;  /* The column text for some columns, see colum_utils */
+  guint        *col_text_len; /* The length of the column text strings in 'col_text' */
 } frame_data;
 
 /*
diff --git a/file.c b/file.c
index fe971f4b965f3e487cf2ec4af6afb63bc60f9dee..65fd2b2b197a78a55a23a71ce84b87529abd0b4e 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1266,6 +1266,7 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
   fdata->flags.ref_time = 0;
   fdata->color_filter = NULL;
   fdata->col_text = NULL;
+  fdata->col_text_len = NULL;
 
   fdata->abs_ts.secs = phdr->ts.secs;
   fdata->abs_ts.nsecs = phdr->ts.nsecs;
index 81c5d206e3f06dca76e66dc942d25ac60dc6e49e..9ccacec645cb1ec6b169aa0c9b11a29e6f0b1363 100644 (file)
@@ -660,12 +660,15 @@ packet_list_change_record(PacketList *packet_list, guint row, gint col, column_i
        g_assert(record->physical_pos == row);
 
        if (record->fdata->col_text && record->fdata->col_text[col] != NULL)
-               /* Column already contains a value. Bail out */
+               /* TODO: Column already contains a value. Bail out */
                return;
 
-       if (!record->fdata->col_text)
+       if (!record->fdata->col_text) {
+               record->fdata->col_text_len = se_alloc0(sizeof(record->fdata->col_text) *
+                                            (packet_list->n_columns-1));
                record->fdata->col_text = se_alloc0(sizeof(record->fdata->col_text) *
                                                                                        (packet_list->n_columns-1));
+       }
 
        switch (cfile.cinfo.col_fmt[col]) {
                case COL_PROTOCOL:
@@ -679,12 +682,15 @@ packet_list_change_record(PacketList *packet_list, guint row, gint col, column_i
                        if (cinfo->col_data[col] != cinfo->col_buf[col]) {
                                /* This is a constant string, so we don't have to copy it */
                                record->fdata->col_text[col] = (gchar *) cinfo->col_data[col];
+                               record->fdata->col_text_len[col] = (guint) strlen(record->fdata->col_text[col]);
                                break;
                        }
                /* !! FALL-THROUGH!! */
 
                default:
-                       record->fdata->col_text[col] = se_strdup(cinfo->col_data[col]);
+                       record->fdata->col_text_len[col] = (guint) strlen(cinfo->col_data[col]);
+                       record->fdata->col_text[col] = se_memdup(cinfo->col_data[col],
+                                                     record->fdata->col_text_len[col] + 1);
                        break;
        }
 }