[glib/wip/nacho/giomodules: 4/5] Factor out a get_gio_module_dir
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/nacho/giomodules: 4/5] Factor out a get_gio_module_dir
- Date: Thu, 22 Oct 2015 06:42:37 +0000 (UTC)
commit 6dedc0364afeafac3bbae7ecbb87249234a4ca85
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu Oct 22 08:18:24 2015 +0200
Factor out a get_gio_module_dir
This also fixes some memory leaks on windows
gio/giomodule.c | 42 ++++++++++++++++++++++++++++--------------
1 files changed, 28 insertions(+), 14 deletions(-)
---
diff --git a/gio/giomodule.c b/gio/giomodule.c
index 56c498c..67ccb3b 100644
--- a/gio/giomodule.c
+++ b/gio/giomodule.c
@@ -950,16 +950,6 @@ _g_io_win32_get_module (void)
return gio_dll;
}
-#undef GIO_MODULE_DIR
-
-/* GIO_MODULE_DIR is used only in code called just once,
- * so no problem leaking this
- */
-#define GIO_MODULE_DIR \
- g_build_filename (g_win32_get_package_installation_directory_of_module (gio_dll), \
- "lib", "gio", "modules", \
- NULL)
-
#endif
void
@@ -1020,13 +1010,36 @@ _g_io_modules_ensure_extension_points_registered (void)
G_UNLOCK (registered_extensions);
}
+static gchar *
+get_gio_module_dir (void)
+{
+ gchar *module_dir;
+
+ module_dir = g_strdup (g_getenv ("GIO_MODULE_DIR"));
+ if (module_dir == NULL)
+ {
+#ifdef G_OS_WIN32
+ gchar *install_dir;
+
+ install_dir = g_win32_get_package_installation_directory_of_module (gio_dll);
+ module_dir = g_build_filename (install_dir,
+ "lib", "gio", "modules",
+ NULL);
+ g_free (install_dir);
+#else
+ module_dir = GIO_MODULE_DIR;
+#endif
+ }
+
+ return module_dir;
+}
+
void
_g_io_modules_ensure_loaded (void)
{
static gboolean loaded_dirs = FALSE;
const char *module_path;
GIOModuleScope *scope;
- const gchar *module_dir;
_g_io_modules_ensure_extension_points_registered ();
@@ -1034,6 +1047,8 @@ _g_io_modules_ensure_loaded (void)
if (!loaded_dirs)
{
+ gchar *module_dir;
+
loaded_dirs = TRUE;
scope = g_io_module_scope_new (G_IO_MODULE_SCOPE_BLOCK_DUPLICATES);
@@ -1055,11 +1070,10 @@ _g_io_modules_ensure_loaded (void)
}
/* Then load the compiled in path */
- module_dir = g_getenv ("GIO_MODULE_DIR");
- if (module_dir == NULL)
- module_dir = GIO_MODULE_DIR;
+ module_dir = get_gio_module_dir ();
g_io_modules_scan_all_in_directory_with_scope (module_dir, scope);
+ g_free (module_dir);
g_io_module_scope_free (scope);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]