Some minor improvements

* destroy/free/shutdown/close in reverse order of allocation
* more static/auto_Xfree
* less variables/strlen/GString
* properly `\0`-terminate string of testcase

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2025-03-07 11:51:30 +01:00
parent b55bf6e4bd
commit 72b99ceb6d
9 changed files with 21 additions and 32 deletions

View File

@@ -177,9 +177,9 @@ callbacks_remove(const char* const plugin_name)
void
callbacks_close(void)
{
g_hash_table_destroy(p_commands);
g_hash_table_destroy(p_timed_functions);
g_hash_table_destroy(p_window_callbacks);
g_hash_table_destroy(p_timed_functions);
g_hash_table_destroy(p_commands);
}
void

View File

@@ -95,9 +95,9 @@ _plugins_shutdown(void)
c_shutdown();
#endif
autocompleters_destroy();
plugin_themes_close();
plugin_settings_close();
plugin_themes_close();
autocompleters_destroy();
callbacks_close();
disco_close();
g_hash_table_destroy(plugins);
@@ -399,7 +399,7 @@ plugins_reload(const char* const name, GString* error_message)
return res;
}
void
static void
_plugins_unloaded_list_dir(const gchar* const dir, GSList** result)
{
GDir* plugins_dir = g_dir_open(dir, 0, NULL);

View File

@@ -100,16 +100,13 @@ python_env_init(void)
python_init_prof();
auto_gchar gchar* plugins_dir = files_get_data_path(DIR_PLUGINS);
GString* path = g_string_new("import sys\n");
g_string_append(path, "sys.path.append(\"");
g_string_append(path, plugins_dir);
g_string_append(path, "/\")\n");
auto_gchar gchar* path = g_strdup_printf(
"import sys\n"
"sys.path.append(\"%s/\")\n", plugins_dir);
PyRun_SimpleString(path->str);
PyRun_SimpleString(path);
python_check_error();
g_string_free(path, TRUE);
allow_python_threads();
}