Manually revert r45669
authordarkjames <darkjames@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 3 Nov 2012 20:51:19 +0000 (20:51 +0000)
committerdarkjames <darkjames@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 3 Nov 2012 20:51:19 +0000 (20:51 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@45884 f5534014-38df-0310-8fa8-9805f1628bb7

epan/epan.c
epan/epan.h
epan/libwireshark.def
epan/proto.c
epan/proto.h
file.c

index bf1a455b271988bc494eba181001818a29a539ee..657b341988790e205f1c221575dc17ecf133c150 100644 (file)
@@ -217,20 +217,6 @@ epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
        wmem_leave_packet_scope();
 }
 
-void
-epan_dissect_reset(epan_dissect_t *edt)
-{
-       /* epan_dissect_cleanup(edt) without freeing tree */
-       g_slist_free(edt->pi.dependent_frames);
-       free_data_sources(&edt->pi);
-       tvb_free_chain(edt->tvb);
-
-       /* epan_dissect_init(edt, create_proto, visible_proto) */
-       edt->pi.dependent_frames = NULL;
-       if (edt->tree)
-               proto_tree_reset(edt->tree);
-}
-
 void
 epan_dissect_cleanup(epan_dissect_t* edt)
 {
index 122111f7cd6ea42e206399a87d402c22be0f0047..492980b7dd26417d45174002e02e6c47eb9fa7ff 100644 (file)
@@ -174,10 +174,6 @@ epan_dissect_cleanup(epan_dissect_t* edt);
 void
 epan_dissect_free(epan_dissect_t* edt);
 
-/** reset edt for next packet dissection */
-void
-epan_dissect_reset(epan_dissect_t *edt);
-
 /** Sets custom column */
 const gchar *
 epan_custom_set(epan_dissect_t *edt, int id, gint occurrence,
index ffffe1b0420715a3cbb0b416f8c3d1f3d059625c..d2be0ef4637e8205cedf86f6d336a2032c8eb481 100644 (file)
@@ -413,7 +413,6 @@ epan_dissect_new
 epan_dissect_prime_dfilter
 epan_dissect_run
 epan_dissect_run_with_taps
-epan_dissect_reset
 epan_get_compiled_version_info
 epan_get_runtime_version_info
 epan_get_version
index bde3fe728ca3ea5f2781c480e9254a7ba4d48de5..14a213674fa6f7e779238c62dc90cb252904072e 100644 (file)
@@ -532,8 +532,9 @@ proto_tree_children_foreach(proto_tree *tree, proto_tree_foreach_func func,
 }
 
 static void
-unref_GPtrArray_value(gpointer key, gpointer value _U_, gpointer user_data _U_)
+free_GPtrArray_value(gpointer key, gpointer value, gpointer user_data _U_)
 {
+       GPtrArray         *ptrs = value;
        gint               hfid = (gint)(long)key;
        header_field_info *hfinfo;
 
@@ -550,12 +551,6 @@ unref_GPtrArray_value(gpointer key, gpointer value _U_, gpointer user_data _U_)
                }
                hfinfo->ref_type = HF_REF_TYPE_NONE;
        }
-}
-
-static void
-free_GPtrArray_value(gpointer value)
-{
-       GPtrArray *ptrs = value;
 
        g_ptr_array_free(ptrs, TRUE);
 }
@@ -566,7 +561,7 @@ free_node_tree_data(tree_data_t *tree_data)
        if (tree_data->interesting_hfids) {
                /* Free all the GPtrArray's in the interesting_hfids hash. */
                g_hash_table_foreach(tree_data->interesting_hfids,
-                       unref_GPtrArray_value, NULL);
+                       free_GPtrArray_value, NULL);
 
                /* And then destroy the hash. */
                g_hash_table_destroy(tree_data->interesting_hfids);
@@ -614,28 +609,6 @@ proto_tree_free(proto_tree *tree)
        free_node_tree_data(tree_data);
 }
 
-void
-proto_tree_reset(proto_tree *tree)
-{
-       tree_data_t *tree_data = PTREE_DATA(tree);
-
-       proto_tree_children_foreach(tree, proto_tree_free_node, NULL);
-
-       /* reset tree */
-       tree->parent = NULL;
-       tree->first_child = NULL;
-       tree->last_child = NULL;
-       tree->next = NULL;
-       PNODE_FINFO(tree) = NULL;
-
-       /* reset tree_data */
-       if (tree_data->interesting_hfids) {
-               g_hash_table_destroy(tree_data->interesting_hfids);
-               tree_data->interesting_hfids = NULL;
-       }
-       tree_data->count = 0;
-}
-
 /* Is the parsing being done for a visible proto_tree or an invisible one?
  * By setting this correctly, the proto_tree creation is sped up by not
  * having to call g_vsnprintf and copy strings around.
@@ -1199,7 +1172,7 @@ proto_lookup_or_create_interesting_hfids(proto_tree *tree,
                if (PTREE_DATA(tree)->interesting_hfids == NULL) {
                        /* Initialize the hash because we now know that it is needed */
                        PTREE_DATA(tree)->interesting_hfids =
-                               g_hash_table_new_full(g_direct_hash, NULL /* g_direct_equal */, NULL, free_GPtrArray_value);
+                               g_hash_table_new(g_direct_hash, NULL /* g_direct_equal */);
                }
 
                ptrs = g_hash_table_lookup(PTREE_DATA(tree)->interesting_hfids,
index dd5e65744133f8f8846591128f0118ced0b9e671..5a2e7bf184ba6c7c6545a06fbfdbfeac13fcf680 100644 (file)
@@ -701,8 +701,6 @@ extern gboolean proto_item_set_expert_flags(proto_item *ti, const int group, con
  @return the new tree root */
 extern proto_tree* proto_tree_create_root(struct _packet_info *pinfo);
 
-extern void proto_tree_reset(proto_tree *tree);
-
 /** Clear memory for entry proto_tree. Clears proto_tree struct also.
  @param tree the tree to free */
 extern void proto_tree_free(proto_tree *tree);
diff --git a/file.c b/file.c
index c4aa90763c0b23987ffbd50fa3193bae7ffe23a6..f5df5089dffab700e18a5a2091ed42bde6ead4a4 100644 (file)
--- a/file.c
+++ b/file.c
@@ -89,7 +89,7 @@ static gulong computed_elapsed;
 static void cf_reset_state(capture_file *cf);
 
 static int read_packet(capture_file *cf, dfilter_t *dfcode,
-    epan_dissect_t *edt, column_info *cinfo, gint64 offset);
+    gboolean create_proto_tree, column_info *cinfo, gint64 offset);
 
 static void rescan_packets(capture_file *cf, const char *action, const char *action_item, gboolean redissect);
 
@@ -495,13 +495,6 @@ calc_progbar_val(capture_file *cf, gint64 size, gint64 file_pos, gchar *status_s
   return progbar_val;
 }
 
-static void
-epan_dissect_finish(epan_dissect_t *edt)
-{
-       if (edt->tree)
-               proto_tree_free(edt->tree);
-}
-
 cf_read_status_t
 cf_read(capture_file *cf, gboolean reloading)
 {
@@ -512,7 +505,6 @@ cf_read(capture_file *cf, gboolean reloading)
   gboolean             stop_flag;
   GTimeVal             start_time;
   dfilter_t           *dfcode;
-  epan_dissect_t       edt;
   gboolean             create_proto_tree;
   guint                tap_flags;
   gboolean             compiled;
@@ -528,9 +520,6 @@ cf_read(capture_file *cf, gboolean reloading)
   tap_flags = union_of_tap_listener_flags();
   create_proto_tree =
     (dfcode != NULL || have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
-  epan_dissect_init(&edt, create_proto_tree, FALSE);
-  if (dfcode != NULL)
-    epan_dissect_prime_dfilter(&edt, dfcode);
 
   reset_tap_listeners();
 
@@ -636,7 +625,7 @@ cf_read(capture_file *cf, gboolean reloading)
           hours even on fast machines) just to see that it was the wrong file. */
        break;
       }
-      read_packet(cf, dfcode, &edt, cinfo, data_offset);
+      read_packet(cf, dfcode, create_proto_tree, cinfo, data_offset);
     } 
   }
   CATCH(OutOfMemoryError) {
@@ -652,7 +641,6 @@ cf_read(capture_file *cf, gboolean reloading)
 #endif
   }
   ENDTRY;
-  epan_dissect_finish(&edt);
 
   /* Free the display name */
   g_free(name_ptr);
@@ -783,7 +771,6 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
   gchar        *err_info;
   int           newly_displayed_packets = 0;
   dfilter_t    *dfcode;
-  epan_dissect_t edt;
   gboolean      create_proto_tree;
   guint         tap_flags;
   gboolean      compiled;
@@ -799,9 +786,6 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
   tap_flags = union_of_tap_listener_flags();
   create_proto_tree =
     (dfcode != NULL || have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
-  epan_dissect_init(&edt, create_proto_tree, FALSE);
-  if (dfcode != NULL)
-    epan_dissect_prime_dfilter(&edt, dfcode);
 
   *err = 0;
 
@@ -828,7 +812,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
           aren't any packets left to read) exit. */
        break;
       }
-      if (read_packet(cf, dfcode, &edt, (column_info *) cinfo, data_offset) != -1) {
+      if (read_packet(cf, dfcode, create_proto_tree, (column_info *) cinfo, data_offset) != -1) {
        newly_displayed_packets++;
       }
       to_read--;
@@ -848,7 +832,6 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
 #endif
   }
   ENDTRY;
-  epan_dissect_finish(&edt);
 
   /* Update the file encapsulation; it might have changed based on the
      packets we've read. */
@@ -907,7 +890,6 @@ cf_finish_tail(capture_file *cf, int *err)
   dfilter_t *dfcode;
   column_info *cinfo;
   gboolean   create_proto_tree;
-  epan_dissect_t edt;
   guint      tap_flags;
   gboolean   compiled;
 
@@ -923,9 +905,6 @@ cf_finish_tail(capture_file *cf, int *err)
   cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
   create_proto_tree =
     (dfcode != NULL || have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
-  epan_dissect_init(&edt, create_proto_tree, FALSE);
-  if (dfcode != NULL)
-    epan_dissect_prime_dfilter(&edt, dfcode);
 
   if (cf->wth == NULL) {
     cf_close(cf);
@@ -943,9 +922,8 @@ cf_finish_tail(capture_file *cf, int *err)
          aren't any packets left to read) exit. */
       break;
     }
-    read_packet(cf, dfcode, &edt, cinfo, data_offset);
+    read_packet(cf, dfcode, create_proto_tree, cinfo, data_offset);
   }
-  epan_dissect_finish(&edt);
 
   /* Cleanup and release all dfilter resources */
   if (dfcode != NULL) {
@@ -1116,28 +1094,36 @@ find_and_mark_frame_depended_upon(gpointer data, gpointer user_data)
 
 static int
 add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
-    dfilter_t *dfcode, epan_dissect_t *edt, column_info *cinfo,
+    dfilter_t *dfcode, gboolean create_proto_tree, column_info *cinfo,
     struct wtap_pkthdr *phdr, const guchar *buf,
     gboolean add_to_packet_list)
 {
-  gint row = -1;
+  epan_dissect_t  edt;
+  gint            row               = -1;
 
   frame_data_set_before_dissect(fdata, &cf->elapsed_time,
                                 &first_ts, prev_dis, prev_cap);
   prev_cap = fdata;
 
-  epan_dissect_run_with_taps(edt, phdr, buf, fdata, cinfo);
+  /* Dissect the frame. */
+  epan_dissect_init(&edt, create_proto_tree, FALSE);
+
+  if (dfcode != NULL) {
+      epan_dissect_prime_dfilter(&edt, dfcode);
+  }
+
+  epan_dissect_run_with_taps(&edt, phdr, buf, fdata, cinfo);
 
   /* If we don't have a display filter, set "passed_dfilter" to 1. */
   if (dfcode != NULL) {
-    fdata->flags.passed_dfilter = dfilter_apply_edt(dfcode, edt) ? 1 : 0;
+    fdata->flags.passed_dfilter = dfilter_apply_edt(dfcode, &edt) ? 1 : 0;
 
     if (fdata->flags.passed_dfilter) {
       /* This frame passed the display filter but it may depend on other
        * (potentially not displayed) frames.  Find those frames and mark them
        * as depended upon.
        */
-      g_slist_foreach(edt->pi.dependent_frames, find_and_mark_frame_depended_upon, cf);
+      g_slist_foreach(edt.pi.dependent_frames, find_and_mark_frame_depended_upon, cf);
     }
   } else
     fdata->flags.passed_dfilter = 1;
@@ -1147,7 +1133,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
 
   if (add_to_packet_list) {
     /* We fill the needed columns from new_packet_list */
-      row = packet_list_append(cinfo, fdata, &edt->pi);
+      row = packet_list_append(cinfo, fdata, &edt.pi);
   }
 
   if (fdata->flags.passed_dfilter || fdata->flags.ref_time)
@@ -1175,7 +1161,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
     cf->last_displayed = fdata->num;
   }
 
-  epan_dissect_reset(edt);
+  epan_dissect_cleanup(&edt);
   return row;
 }
 
@@ -1183,7 +1169,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
 /* returns the row of the new packet in the packet list or -1 if not displayed */
 static int
 read_packet(capture_file *cf, dfilter_t *dfcode,
-            epan_dissect_t *edt, column_info *cinfo, gint64 offset)
+            gboolean create_proto_tree, column_info *cinfo, gint64 offset)
 {
   struct wtap_pkthdr *phdr = wtap_phdr(cf->wth);
   const guchar *buf = wtap_buf_ptr(cf->wth);
@@ -1228,7 +1214,7 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
 
     if (!cf->redissecting) {
       row = add_packet_to_packet_list(fdata, cf, dfcode,
-                                      edt, cinfo,
+                                      create_proto_tree, cinfo,
                                       phdr, buf, TRUE);
     }
   }
@@ -1769,7 +1755,6 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
   int         progbar_quantum;
   dfilter_t  *dfcode;
   column_info *cinfo;
-  epan_dissect_t edt;
   gboolean    create_proto_tree;
   guint       tap_flags;
   gboolean    add_to_packet_list = FALSE;
@@ -1788,9 +1773,6 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
   cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
   create_proto_tree =
     (dfcode != NULL || have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
-  epan_dissect_init(&edt, create_proto_tree, FALSE);
-  if (dfcode != NULL)
-    epan_dissect_prime_dfilter(&edt, dfcode);
 
   reset_tap_listeners();
   /* Which frame, if any, is the currently selected frame?
@@ -1942,7 +1924,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
       preceding_frame_num = prev_frame_num;
       preceding_frame = prev_frame;
     }
-    add_packet_to_packet_list(fdata, cf, dfcode, &edt,
+    add_packet_to_packet_list(fdata, cf, dfcode, create_proto_tree,
                                     cinfo, &cf->phdr, cf->pd,
                                     add_to_packet_list);
 
@@ -1965,7 +1947,6 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
     prev_frame_num = fdata->num;
     prev_frame = fdata;
   }
-  epan_dissect_finish(&edt);
 
   /* We are done redissecting the packet list. */
   cf->redissecting = FALSE;