diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2017-09-10 23:38:36 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2017-09-11 16:48:49 +0000 |
commit | 69f0cb0cef3e8cc6b49073768f76ff1046ded8b5 (patch) | |
tree | 7a6314bf9e04fc5575a8c61df5f62c68be9e76c8 /wsutil/filesystem.c | |
parent | e7aa63746ba630d88032394f4869fca2c87853a8 (diff) |
wsutil: Initialize and store plugin personal dir
Obviate allocation on every call to get_plugins_pers_dir().
Change-Id: I089ae499f93739d490d4552f59b5db5996f7d26f
Reviewed-on: https://code.wireshark.org/review/23495
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'wsutil/filesystem.c')
-rw-r--r-- | wsutil/filesystem.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index 939e4d3f05..2a2c4bab5f 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -959,6 +959,7 @@ get_datafile_dir(void) * configure script. */ static char *plugin_dir = NULL; +static char *plugin_pers_dir = NULL; static void init_plugin_dir(void) @@ -1034,6 +1035,12 @@ init_plugin_dir(void) } #endif /* HAVE_PLUGINS || HAVE_LUA */ +static void +init_plugin_pers_dir(void) +{ + plugin_pers_dir = get_persconffile_path(PLUGINS_DIR_NAME, FALSE); +} + /* * Get the directory in which the plugins are stored. */ @@ -1048,6 +1055,15 @@ get_plugin_dir(void) #endif } +/* Get the personal plugin dir */ +const char * +get_plugins_pers_dir(void) +{ + if (!plugin_pers_dir) + init_plugin_pers_dir(); + return plugin_pers_dir; +} + #if defined(HAVE_EXTCAP) /* * Find the directory where the extcap hooks are stored. @@ -1883,14 +1899,6 @@ get_datafile_path(const char *filename) } } -/* Get the personal plugin dir */ -/* Return value is malloced so the caller should g_free() it. */ -char * -get_plugins_pers_dir(void) -{ - return get_persconffile_path(PLUGINS_DIR_NAME, FALSE); -} - /* * Return an error message for UNIX-style errno indications on open or * create operations. @@ -2227,6 +2235,8 @@ free_progdirs(void) #if defined(HAVE_PLUGINS) || defined(HAVE_LUA) g_free(plugin_dir); plugin_dir = NULL; + g_free(plugin_pers_dir); + plugin_pers_dir = NULL; #endif #ifdef HAVE_EXTCAP g_free(extcap_dir); |