2.13.1
[platform/upstream/glib.git] / gobject / gboxed.c
index 1ef11b5..cab8164 100644 (file)
@@ -93,30 +93,6 @@ value_free (gpointer boxed)
   g_free (value);
 }
 
-static gpointer
-gdate_copy (gpointer boxed)
-{
-  const GDate *date = (const GDate*) boxed;
-
-  return g_date_new_julian (g_date_get_julian (date));
-}
-
-static gpointer
-gstring_copy (gpointer boxed)
-{
-  const GString *src_gstring = boxed;
-
-  return g_string_new_len (src_gstring->str, src_gstring->len);
-}
-
-static void
-gstring_free (gpointer boxed)
-{
-  GString *gstring = boxed;
-
-  g_string_free (gstring, TRUE);
-}
-
 void
 g_boxed_type_init (void) 
 {
@@ -150,7 +126,7 @@ g_closure_get_type (void)
   static GType type_id = 0;
 
   if (!type_id)
-    type_id = g_boxed_type_register_static ("GClosure",
+    type_id = g_boxed_type_register_static (g_intern_static_string ("GClosure"),
                                            (GBoxedCopyFunc) g_closure_ref,
                                            (GBoxedFreeFunc) g_closure_unref);
   return type_id;
@@ -162,7 +138,7 @@ g_value_get_type (void)
   static GType type_id = 0;
 
   if (!type_id)
-    type_id = g_boxed_type_register_static ("GValue",
+    type_id = g_boxed_type_register_static (g_intern_static_string ("GValue"),
                                            value_copy,
                                            value_free);
   return type_id;
@@ -174,19 +150,27 @@ g_value_array_get_type (void)
   static GType type_id = 0;
 
   if (!type_id)
-    type_id = g_boxed_type_register_static ("GValueArray",
+    type_id = g_boxed_type_register_static (g_intern_static_string ("GValueArray"),
                                            (GBoxedCopyFunc) g_value_array_copy,
                                            (GBoxedFreeFunc) g_value_array_free);
   return type_id;
 }
 
+static gpointer
+gdate_copy (gpointer boxed)
+{
+  const GDate *date = (const GDate*) boxed;
+
+  return g_date_new_julian (g_date_get_julian (date));
+}
+
 GType
 g_date_get_type (void)
 {
   static GType type_id = 0;
 
   if (!type_id)
-    type_id = g_boxed_type_register_static ("GDate",
+    type_id = g_boxed_type_register_static (g_intern_static_string ("GDate"),
                                            (GBoxedCopyFunc) gdate_copy,
                                            (GBoxedFreeFunc) g_date_free);
   return type_id;
@@ -198,24 +182,65 @@ g_strv_get_type (void)
   static GType type_id = 0;
 
   if (!type_id)
-    type_id = g_boxed_type_register_static ("GStrv",
+    type_id = g_boxed_type_register_static (g_intern_static_string ("GStrv"),
                                            (GBoxedCopyFunc) g_strdupv,
                                            (GBoxedFreeFunc) g_strfreev);
   return type_id;
 }
 
+static gpointer
+gstring_copy (gpointer boxed)
+{
+  const GString *src_gstring = boxed;
+
+  return g_string_new_len (src_gstring->str, src_gstring->len);
+}
+
+static void
+gstring_free (gpointer boxed)
+{
+  GString *gstring = boxed;
+
+  g_string_free (gstring, TRUE);
+}
+
 GType
 g_gstring_get_type (void)
 {
   static GType type_id = 0;
 
   if (!type_id)
-    type_id = g_boxed_type_register_static ("GString", /* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
+    type_id = g_boxed_type_register_static (g_intern_static_string ("GString"),
+                                            /* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
                                            gstring_copy,
                                            gstring_free);
   return type_id;
 }
 
+static gpointer
+hash_table_copy (gpointer boxed)
+{
+  GHashTable *hash_table = boxed;
+  return g_hash_table_ref (hash_table);
+}
+
+static void
+hash_table_free (gpointer boxed)
+{
+  GHashTable *hash_table = boxed;
+  g_hash_table_unref (hash_table);
+}
+
+GType
+g_hash_table_get_type (void)
+{
+  static GType type_id = 0;
+  if (!type_id)
+    type_id = g_boxed_type_register_static (g_intern_static_string ("GHashTable"),
+                                           hash_table_copy, hash_table_free);
+  return type_id;
+}
+
 static void
 boxed_proxy_value_init (GValue *value)
 {