[glib/wip/nacho/giomodules: 1/2] 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: 1/2] Factor out a get_gio_module_dir
- Date: Thu, 22 Oct 2015 06:38:17 +0000 (UTC)
commit 93af699aece91990240f020f630108659623afb7
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 | 41 ++++++++++++++++++++++++++---------------
1 files changed, 26 insertions(+), 15 deletions(-)
---
diff --git a/gio/giomodule.c b/gio/giomodule.c
index 56c498c..3fdde19 100644
--- a/gio/giomodule.c
+++ b/gio/giomodule.c
@@ -950,18 +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
_g_io_modules_ensure_extension_points_registered (void)
{
@@ -1020,6 +1008,30 @@ _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)
{
@@ -1055,11 +1067,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]