Replace static privates by privates
authorMatthias Clasen <mclasen@redhat.com>
Mon, 3 Oct 2011 01:57:40 +0000 (21:57 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 3 Oct 2011 02:11:33 +0000 (22:11 -0400)
GStaticPrivate is heading for deprecation soon, and GPrivate
can replace these uses now.

gio/gcancellable.c
glib/gutf8.c
gmodule/gmodule.c

index 7ebbdf4..5b08880 100644 (file)
@@ -57,7 +57,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 G_DEFINE_TYPE (GCancellable, g_cancellable, G_TYPE_OBJECT);
 
-static GStaticPrivate current_cancellable = G_STATIC_PRIVATE_INIT;
+static GPrivate current_cancellable;
 G_LOCK_DEFINE_STATIC(cancellable);
 static GCond *cancellable_cond = NULL;
 
@@ -201,9 +201,9 @@ g_cancellable_push_current (GCancellable *cancellable)
 
   g_return_if_fail (cancellable != NULL);
 
-  l = g_static_private_get (&current_cancellable);
+  l = g_private_get (&current_cancellable);
   l = g_slist_prepend (l, cancellable);
-  g_static_private_set (&current_cancellable, l, NULL);
+  g_private_set (&current_cancellable, l);
 }
 
 /**
@@ -218,13 +218,13 @@ g_cancellable_pop_current (GCancellable *cancellable)
 {
   GSList *l;
 
-  l = g_static_private_get (&current_cancellable);
+  l = g_private_get (&current_cancellable);
 
   g_return_if_fail (l != NULL);
   g_return_if_fail (l->data == cancellable);
 
   l = g_slist_delete_link (l, l);
-  g_static_private_set (&current_cancellable, l, NULL);
+  g_private_set (&current_cancellable, l);
 }
 
 /**
@@ -240,7 +240,7 @@ g_cancellable_get_current  (void)
 {
   GSList *l;
 
-  l = g_static_private_get (&current_cancellable);
+  l = g_private_get (&current_cancellable);
   if (l == NULL)
     return NULL;
 
index f6d721b..3558c20 100644 (file)
@@ -581,20 +581,20 @@ charset_cache_free (gpointer data)
  *
  * The string returned in @charset is not allocated, and should not be
  * freed.
- * 
+ *
  * Return value: %TRUE if the returned charset is UTF-8
  **/
 gboolean
-g_get_charset (const char **charset) 
+g_get_charset (const char **charset)
 {
-  static GStaticPrivate cache_private = G_STATIC_PRIVATE_INIT;
-  GCharsetCache *cache = g_static_private_get (&cache_private);
+  static GPrivate cache_private = G_PRIVATE_INIT (charset_cache_free);
+  GCharsetCache *cache = g_private_get (&cache_private);
   const gchar *raw;
 
   if (!cache)
     {
       cache = g_new0 (GCharsetCache, 1);
-      g_static_private_set (&cache_private, cache, charset_cache_free);
+      g_private_set (&cache_private, cache);
     }
 
   G_LOCK (aliases);
index 4d7e811..c1a6486 100644 (file)
@@ -91,7 +91,7 @@ static inline GModule*        g_module_find_by_name   (const gchar    *name);
 /* --- variables --- */
 static GModule      *modules = NULL;
 static GModule      *main_module = NULL;
-static GStaticPrivate module_error_private = G_STATIC_PRIVATE_INIT;
+static GPrivate       module_error_private = G_PRIVATE_INIT (g_free);
 static gboolean              module_debug_initialized = FALSE;
 static guint         module_debug_flags = 0;
 
@@ -135,7 +135,7 @@ g_module_find_by_name (const gchar *name)
 static inline void
 g_module_set_error_unduped (gchar *error)
 {
-  g_static_private_set (&module_error_private, error, g_free);
+  g_private_replace (&module_error_private, error);
   errno = 0;
 }
 
@@ -600,7 +600,7 @@ g_module_make_resident (GModule *module)
 const gchar *
 g_module_error (void)
 {
-  return g_static_private_get (&module_error_private);
+  return g_private_get (&module_error_private);
 }
 
 gboolean