aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/wtap.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2021-11-26 20:59:15 +0000
committerGuy Harris <gharris@sonic.net>2021-11-27 08:41:01 +0000
commitc15f2aadc1aef3f4855c682ff7f686d5f63088cb (patch)
treef0042090e6a0f7374e36b70da83ce3009dffd071 /wiretap/wtap.c
parentba85d8ef4d657f3f852eb8ee7e0cc6c2141d086e (diff)
epan: Initialize wiretap
Clients of libwireshark should not be required to initialize explicitly wiretap, if they don't use it themselves.
Diffstat (limited to 'wiretap/wtap.c')
-rw-r--r--wiretap/wtap.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index f1fdfc807b..5d40b9c1ce 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -25,6 +25,8 @@
#include <wsutil/plugins.h>
#endif
+static gboolean wiretap_initialized = FALSE;
+
#ifdef HAVE_PLUGINS
static plugins_t *libwiretap_plugins = NULL;
#endif
@@ -1838,6 +1840,9 @@ wtap_full_file_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf,
void
wtap_init(gboolean load_wiretap_plugins)
{
+ if (wiretap_initialized)
+ return;
+
init_open_routines();
wtap_opttypes_initialize();
wtap_init_encap_types();
@@ -1848,6 +1853,7 @@ wtap_init(gboolean load_wiretap_plugins)
#endif
g_slist_foreach(wtap_plugins, call_plugin_register_wtap_module, NULL);
}
+ wiretap_initialized = TRUE;
}
/*
@@ -1856,6 +1862,9 @@ wtap_init(gboolean load_wiretap_plugins)
void
wtap_cleanup(void)
{
+ if (!wiretap_initialized)
+ return;
+
wtap_cleanup_encap_types();
wtap_opttypes_cleanup();
ws_buffer_cleanup();
@@ -1866,6 +1875,7 @@ wtap_cleanup(void)
plugins_cleanup(libwiretap_plugins);
libwiretap_plugins = NULL;
#endif
+ wiretap_initialized = FALSE;
}
/*