From f9f6fa74fd78d78b268b49b84ad9f37175321cdc Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 15 Jul 2014 15:48:29 -0700 Subject: Get rid of cf_reset_state() - it's only called from one place. Change-Id: I48521bbaa898c99286e6bb5e40281aba7701ed4d Reviewed-on: https://code.wireshark.org/review/3062 Reviewed-by: Guy Harris --- file.c | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index 819660cf61..25d1ec2684 100644 --- a/file.c +++ b/file.c @@ -106,8 +106,6 @@ gboolean auto_scroll_live; #endif -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); @@ -439,22 +437,21 @@ cf_add_encapsulation_type(capture_file *cf, int encap) g_array_append_val(cf->linktypes, encap); } -/* - * Reset the state for the currently closed file, but don't do the - * UI callbacks; this is for use in "cf_open()", where we don't - * want the UI to go from "file open" to "file closed" back to - * "file open", we want it to go from "old file open" to "new file - * open and being read". - * - * XXX - currently, cf_open() calls cf_close(), rather than - * cf_reset_state(). - */ -static void -cf_reset_state(capture_file *cf) +/* Reset everything to a pristine state */ +void +cf_close(capture_file *cf) { + if (cf->state == FILE_CLOSED) + return; /* Nothing to do */ + /* Die if we're in the middle of reading a file. */ g_assert(cf->state != FILE_READ_IN_PROGRESS); + cf_callback_invoke(cf_cb_file_closing, cf); + + /* close things, if not already closed before */ + color_filters_cleanup(); + if (cf->wth) { wtap_close(cf->wth); cf->wth = NULL; @@ -516,25 +513,13 @@ cf_reset_state(capture_file *cf) reset_tap_listeners(); + epan_free(cf->epan); + cf->epan = NULL; + /* We have no file open. */ cf->state = FILE_CLOSED; -} - -/* Reset everything to a pristine state */ -void -cf_close(capture_file *cf) -{ - if (cf->state != FILE_CLOSED) { - cf_callback_invoke(cf_cb_file_closing, cf); - - /* close things, if not already closed before */ - color_filters_cleanup(); - cf_reset_state(cf); - epan_free(cf->epan); - cf->epan = NULL; - cf_callback_invoke(cf_cb_file_closed, cf); - } + cf_callback_invoke(cf_cb_file_closed, cf); } static float -- cgit v1.2.3