[glib/wip/gcleanup: 49/78] giomodule: Cleanup global data



commit 2a03fdfe9fa64d3c6389ee2788778f6ab63d9773
Author: Stef Walter <stefw gnome org>
Date:   Thu Nov 7 23:00:08 2013 +0100

    giomodule: Cleanup global data
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711799

 gio/giomodule.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/gio/giomodule.c b/gio/giomodule.c
index 6297f22..76b61ae 100644
--- a/gio/giomodule.c
+++ b/gio/giomodule.c
@@ -693,7 +693,8 @@ _g_io_module_get_default_type (const gchar *extension_point,
     }
   else
     {
-      default_modules = g_hash_table_new (g_str_hash, g_str_equal);
+      default_modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+      G_CLEANUP_IN_PHASE (default_modules, g_hash_table_unref, G_CLEANUP_PHASE_EARLY);
     }
 
   _g_io_modules_ensure_loaded ();
@@ -817,7 +818,9 @@ _g_io_module_get_default (const gchar         *extension_point,
     }
   else
     {
-      default_modules = g_hash_table_new (g_str_hash, g_str_equal);
+      default_modules = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                               g_free, g_object_unref);
+      G_CLEANUP_IN_PHASE (default_modules, g_hash_table_unref, G_CLEANUP_PHASE_EARLY);
     }
 
   _g_io_modules_ensure_loaded ();
@@ -1126,10 +1129,12 @@ g_io_extension_point_register (const char *name)
   
   G_LOCK (extension_points);
   if (extension_points == NULL)
-    extension_points = g_hash_table_new_full (g_str_hash,
-                                             g_str_equal,
-                                             NULL,
-                                             (GDestroyNotify)g_io_extension_point_free);
+    {
+      extension_points = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
+                                                (GDestroyNotify)g_io_extension_point_free);
+      G_CLEANUP_IN_PHASE (extension_points, g_hash_table_remove_all, G_CLEANUP_PHASE_EARLY);
+      G_CLEANUP_IN_PHASE (extension_points, g_hash_table_unref, G_CLEANUP_PHASE_LATE);
+    }
 
   ep = g_hash_table_lookup (extension_points, name);
   if (ep != NULL)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]