diff options
author | Dario Lombardo <lomato@gmail.com> | 2017-02-04 16:26:34 +0100 |
---|---|---|
committer | Dario Lombardo <lomato@gmail.com> | 2017-02-14 10:22:20 +0000 |
commit | 7c0c580c4b0093437ee81e11934ef5b8d27a5bb4 (patch) | |
tree | 45d46758e2ce26b82b8a5d066bd9b1f23e1165ec /wiretap | |
parent | ae0bdcc78c6cb2719e7aa5ae24e80584dec488a3 (diff) |
wiretap: add cleanup routine.
The cleanup routine has been added to exit section of the applications.
Those which required a exit restyle have been patched as well.
Change-Id: I3a8787f0718ac7fef00dc58176869c7510fda7b1
Reviewed-on: https://code.wireshark.org/review/19949
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/merge.h | 3 | ||||
-rw-r--r-- | wiretap/wtap.c | 18 | ||||
-rw-r--r-- | wiretap/wtap.h | 3 | ||||
-rw-r--r-- | wiretap/wtap_opttypes.c | 20 | ||||
-rw-r--r-- | wiretap/wtap_opttypes.h | 4 |
5 files changed, 47 insertions, 1 deletions
diff --git a/wiretap/merge.h b/wiretap/merge.h index 502c0955d3..21d0861cd8 100644 --- a/wiretap/merge.h +++ b/wiretap/merge.h @@ -59,7 +59,8 @@ typedef enum { MERGE_ERR_CANT_READ_INFILE, MERGE_ERR_BAD_PHDR_INTERFACE_ID, MERGE_ERR_CANT_WRITE_OUTFILE, - MERGE_ERR_CANT_CLOSE_OUTFILE + MERGE_ERR_CANT_CLOSE_OUTFILE, + MERGE_ERR_INVALID_OPTION } merge_result; diff --git a/wiretap/wtap.c b/wiretap/wtap.c index e14953b624..6473d43ee9 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -936,6 +936,13 @@ static void wtap_init_encap_types(void) { g_array_append_vals(encap_table_arr,encap_table_base,wtap_num_encap_types); } +static void wtap_cleanup_encap_types(void) { + if (encap_table_arr) { + g_array_free(encap_table_arr, TRUE); + encap_table_arr = NULL; + } +} + int wtap_get_num_encap_types(void) { return wtap_num_encap_types; } @@ -1429,6 +1436,17 @@ wtap_init(void) } /* + * Cleanup the library + */ +void +wtap_cleanup(void) +{ + wtap_cleanup_encap_types(); + wtap_opttypes_cleanup(); + ws_buffer_cleanup(); +} + +/* * Editor modelines - http://www.wireshark.org/tools/modelines.html * * Local variables: diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 5ce3cf436a..d1ed5d7577 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1972,6 +1972,9 @@ void wtap_deregister_file_type_subtype(const int file_type_subtype); WS_DLL_PUBLIC int wtap_register_encap_type(const char* name, const char* short_name); +/*** Cleanup the interal library structures */ +WS_DLL_PUBLIC +void wtap_cleanup(void); /** * Wiretap error codes. diff --git a/wiretap/wtap_opttypes.c b/wiretap/wtap_opttypes.c index 199280bfd6..6f09b1ba03 100644 --- a/wiretap/wtap_opttypes.c +++ b/wiretap/wtap_opttypes.c @@ -1231,3 +1231,23 @@ void wtap_opttypes_initialize(void) wtap_opttype_option_register(&isb_block, OPT_ISB_OSDROP, &isb_osdrop); wtap_opttype_option_register(&isb_block, OPT_ISB_USRDELIV, &isb_usrdeliv); } + +void wtap_opttypes_cleanup(void) +{ + if (blocktype_list[WTAP_BLOCK_NG_SECTION]->options) { + g_array_free(blocktype_list[WTAP_BLOCK_NG_SECTION]->options, TRUE); + blocktype_list[WTAP_BLOCK_NG_SECTION]->options = NULL; + } + if (blocktype_list[WTAP_BLOCK_IF_DESCR]->options) { + g_array_free(blocktype_list[WTAP_BLOCK_IF_DESCR]->options, TRUE); + blocktype_list[WTAP_BLOCK_IF_DESCR]->options = NULL; + } + if (blocktype_list[WTAP_BLOCK_NG_NRB]->options) { + g_array_free(blocktype_list[WTAP_BLOCK_NG_NRB]->options, TRUE); + blocktype_list[WTAP_BLOCK_NG_NRB]->options = NULL; + } + if (blocktype_list[WTAP_BLOCK_IF_STATS]->options) { + g_array_free(blocktype_list[WTAP_BLOCK_IF_STATS]->options, TRUE); + blocktype_list[WTAP_BLOCK_IF_STATS]->options = NULL; + } +} diff --git a/wiretap/wtap_opttypes.h b/wiretap/wtap_opttypes.h index 44c5f064dd..b508eb35af 100644 --- a/wiretap/wtap_opttypes.h +++ b/wiretap/wtap_opttypes.h @@ -520,6 +520,10 @@ WS_DLL_PUBLIC void wtap_block_foreach_option(wtap_block_t block, wtap_block_fore WS_DLL_PUBLIC int wtap_opttype_register_custom_block_type(const char* name, const char* description, wtap_block_create_func create, wtap_mand_free_func free_mand, wtap_mand_copy_func copy_mand); +/** Cleanup the internal structures + */ +WS_DLL_PUBLIC void wtap_opttypes_cleanup(void); + #ifdef __cplusplus } #endif /* __cplusplus */ |