Introduce frame_data_cleanup() and start using it
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Sun, 20 Sep 2009 18:18:29 +0000 (18:18 -0000)
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Sun, 20 Sep 2009 18:18:29 +0000 (18:18 -0000)
svn path=/trunk/; revision=30023

epan/frame_data.c
epan/frame_data.h
epan/libwireshark.def
file.c
rawshark.c
tshark.c

index c75672f0ec882aade046ac1b0b36dc4ec4d4f73e..f1ab3a840aeef01d841e45278479dcd825ae4fb4 100644 (file)
@@ -259,3 +259,12 @@ frame_data_init(frame_data *fdata, capture_file *cf,
   *prev_cap_ts = fdata->abs_ts;
 }
 
+void
+frame_data_cleanup(frame_data *fdata)
+{
+  if (fdata->pfd)
+    g_slist_free(fdata->pfd);
+
+  fdata->pfd = NULL;
+}
+
index 354f8d0e2f4539999709c11146f9af3e81dafc49..74469d5333bfcdcfd10d6b3cfdb2a6b02d0f4187 100644 (file)
@@ -84,4 +84,7 @@ extern void p_remove_proto_data(frame_data *fd, int proto);
 /* compare two frame_datas */
 extern gint frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field);
 
+extern void frame_data_cleanup(frame_data *fdata);
+
 #endif  /* __FRAME_DATA__ */
+
index 1a9d9f6d445e6b54f27955194a08452413bf5f07..d541022fd70a647c412a2154cc0ab4089cc69fb9 100644 (file)
@@ -423,6 +423,7 @@ fragment_get_tot_len
 fragment_set_partial_reassembly
 fragment_set_tot_len
 fragment_table_init
+frame_data_cleanup
 frame_data_compare
 frame_data_init
 free_prefs
diff --git a/file.c b/file.c
index 4099c3dc8635d38edb7ebf09b3cb3f8eb0d1b183..7267979036eabfaee296b517105a258f98bb18b7 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1844,10 +1844,7 @@ rescan_packets_old(capture_file *cf, const char *action, const char *action_item
        * "init_dissection()"), and null out the GSList pointer.
           */
       fdata->flags.visited = 0;
-      if (fdata->pfd) {
-               g_slist_free(fdata->pfd);
-        fdata->pfd = NULL;
-      }
+      frame_data_cleanup(fdata);
     }
 
     if (!wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header,
@@ -1903,10 +1900,7 @@ rescan_packets_old(capture_file *cf, const char *action, const char *action_item
        until it finishes.  Should we just stick them with that? */
     for (; fdata != NULL; fdata = fdata->next) {
       fdata->flags.visited = 0;
-      if (fdata->pfd) {
-               g_slist_free(fdata->pfd);
-        fdata->pfd = NULL;
-      }
+      frame_data_cleanup(fdata);
     }
   }
 
@@ -2148,11 +2142,9 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
        * data (the per-frame data itself was freed by
        * "init_dissection()"), and null out the GSList pointer. */
       fdata->flags.visited = 0;
-      if (fdata->pfd) {
-               g_slist_free(fdata->pfd);
-        fdata->pfd = NULL;
-      }
-         /* cleanup_dissection() calls se_free_all(); 
+      frame_data_cleanup(fdata);
+
+         /* cleanup_dissection() calls se_free_all();
           * And after that fdata->col_text (which is allocated using se_alloc0())
           * no longer points to valid memory.
           */
@@ -2214,10 +2206,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
        until it finishes.  Should we just stick them with that? */
     for (; fdata != NULL; fdata = fdata->next) {
       fdata->flags.visited = 0;
-      if (fdata->pfd) {
-               g_slist_free(fdata->pfd);
-        fdata->pfd = NULL;
-      }
+      frame_data_cleanup(fdata);
     }
   }
 
index 06b2f80ea6c13049fc0588ef3da7ac2f2341ce06..fc9c11ff93809413b509e3d20f0cdbd489e17ada 100644 (file)
@@ -995,14 +995,6 @@ load_cap_file(capture_file *cf)
   return err;
 }
 
-/* Free up all data attached to a "frame_data" structure. */
-static void
-clear_fdata(frame_data *fdata)
-{
-  if (fdata->pfd)
-    g_slist_free(fdata->pfd);
-}
-
 static gboolean
 process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
                const guchar *pd)
@@ -1108,7 +1100,7 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
   }
 
   epan_dissect_cleanup(&edt);
-  clear_fdata(&fdata);
+  frame_data_cleanup(&fdata);
 
   return passed;
 }
index 11387b0b85d2db2e5fc7872b5ddf0c996e16a6d1..d6f13de8401d50e33224bac7f3860275bba0476d 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -2336,14 +2336,6 @@ out:
   return err;
 }
 
-/* Free up all data attached to a "frame_data" structure. */
-static void
-clear_fdata(frame_data *fdata)
-{
-  if (fdata->pfd)
-    g_slist_free(fdata->pfd);
-}
-
 static gboolean
 process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
                union wtap_pseudo_header *pseudo_header, const guchar *pd,
@@ -2469,7 +2461,7 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
 
   if (do_dissection) {
     epan_dissect_cleanup(&edt);
-    clear_fdata(&fdata);
+    frame_data_cleanup(&fdata);
   }
   return passed;
 }