From 2e282e75671cd256ad0acc302a1d8ddf7a1a17e7 Mon Sep 17 00:00:00 2001 From: Kovarththanan Rajaratnam Date: Sun, 20 Sep 2009 18:18:29 +0000 Subject: [PATCH] Introduce frame_data_cleanup() and start using it svn path=/trunk/; revision=30023 --- epan/frame_data.c | 9 +++++++++ epan/frame_data.h | 3 +++ epan/libwireshark.def | 1 + file.c | 23 ++++++----------------- rawshark.c | 10 +--------- tshark.c | 10 +--------- 6 files changed, 21 insertions(+), 35 deletions(-) diff --git a/epan/frame_data.c b/epan/frame_data.c index c75672f0ec..f1ab3a840a 100644 --- a/epan/frame_data.c +++ b/epan/frame_data.c @@ -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; +} + diff --git a/epan/frame_data.h b/epan/frame_data.h index 354f8d0e2f..74469d5333 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -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__ */ + diff --git a/epan/libwireshark.def b/epan/libwireshark.def index 1a9d9f6d44..d541022fd7 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -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 4099c3dc86..7267979036 100644 --- 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); } } diff --git a/rawshark.c b/rawshark.c index 06b2f80ea6..fc9c11ff93 100644 --- a/rawshark.c +++ b/rawshark.c @@ -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; } diff --git a/tshark.c b/tshark.c index 11387b0b85..d6f13de840 100644 --- 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; } -- 2.34.1