+2005-08-31 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/glib.symbols:
+ * glib/gquark.h:
+ * glib/gdataset.c:
+
2005-08-28 Matthias Clasen <mclasen@redhat.com>
* glib/giochannel.c: Unify some near-duplicate strings. (#314654,
+2005-08-31 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/glib.symbols:
+ * glib/gquark.h:
+ * glib/gdataset.c:
+
2005-08-28 Matthias Clasen <mclasen@redhat.com>
* glib/giochannel.c: Unify some near-duplicate strings. (#314654,
+2005-08-31 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/glib.symbols:
+ * glib/gquark.h:
+ * glib/gdataset.c:
+
2005-08-28 Matthias Clasen <mclasen@redhat.com>
* glib/giochannel.c: Unify some near-duplicate strings. (#314654,
+2005-08-31 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/tmpl/quarks.sgml:
+ * glib/glib-sections.txt: Add string interning functions.
+
2005-08-30 Matthias Clasen <mclasen@redhat.com>
* glib/tmpl/arrays.sgml:
g_quark_from_static_string
g_quark_to_string
g_quark_try_string
-
+g_intern_string
+g_intern_static_string
</SECTION>
<SECTION>
<para>
To find the #GQuark corresponding to a given string, use g_quark_try_string().
</para>
+<para>
+Another use for the string pool maintained for the quark functions is string
+interning, using g_intern_string() or g_intern_static_string(). An interned string
+is a canonical representation for a string. One important advantage of interned strings
+is that they can be compared for equality by a simple pointer comparision, rather than
+using strcmp().
+</para>
<!-- ##### SECTION See_Also ##### -->
<para>
return quark;
}
+/**
+ * g_intern_string:
+ * @string: a string
+ *
+ * Returns a canonical representation for @string. Interned strings can
+ * be compared for equality by comparing the pointers, instead of using strcmp().
+ *
+ * Returns: a canonical representation for the string
+ *
+ * Since: 2.10
+ */
+G_CONST_RETURN gchar*
+g_intern_string (const gchar *string)
+{
+ return string ? g_quark_to_string (g_quark_from_string (string)) : NULL;
+}
+
+/**
+ * g_intern_static_string:
+ * @string: a static string
+ *
+ * Returns a canonical representation for @string. Interned strings can
+ * be compared for equality by comparing the pointers, instead of using strcmp().
+ * g_intern_static_string() does not copy the string, therefore @string must
+ * not be freed or modified.
+ *
+ * Returns: a canonical representation for the string
+ *
+ * Since: 2.10
+ */
+G_CONST_RETURN gchar*
+g_intern_static_string (const gchar *string)
+{
+ return string ? g_quark_to_string (g_quark_from_static_string (string)) : NULL;
+}
+
+
+
#define __G_DATASET_C__
#include "galiasdef.c"
g_dataset_id_get_data
g_dataset_id_remove_no_notify
g_dataset_id_set_data_full
+#endif
+#endif
+
+#if IN_HEADER(__G_QUARK_H__)
+#if IN_FILE(__G_DATASET_C__)
g_quark_from_static_string
g_quark_from_string
g_quark_to_string G_GNUC_CONST
g_quark_try_string
+g_intern_string
+g_intern_static_string
#endif
#endif
GQuark g_quark_from_string (const gchar *string);
G_CONST_RETURN gchar* g_quark_to_string (GQuark quark) G_GNUC_CONST;
+G_CONST_RETURN gchar* g_intern_string (const gchar *string);
+G_CONST_RETURN gchar* g_intern_static_string (const gchar *string);
+
+
G_END_DECLS
#endif /* __G_QUARK_H__ */