From f50d64c6ad05eb18bb318c578abc6f63b5d2ba7a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 17 Jun 2007 07:43:34 +0000 Subject: [PATCH] Accept NULL and return GQuark value of zero. (#446859) 2007-06-17 Behdad Esfahbod * glib/gdataset.c (g_quark_from_string), (g_quark_from_static_string): Accept NULL and return GQuark value of zero. (#446859) svn path=/trunk/; revision=5572 --- ChangeLog | 6 ++++++ docs/reference/ChangeLog | 4 ++++ docs/reference/glib/tmpl/quarks.sgml | 15 ++++++++------- glib/gdataset.c | 6 ++++-- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a996de..4b3e1d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-06-17 Behdad Esfahbod + + * glib/gdataset.c (g_quark_from_string), + (g_quark_from_static_string): Accept NULL and return GQuark + value of zero. (#446859) + 2007-06-16 Mathias Hasselmann * glib/gstring.c: Correctly use g_printf_string_upper_bound diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index fc77b44..f0be2ad 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +2007-06-17 Behdad Esfahbod + + * glib/tmpl/quarks.sgml: + 2007-06-16 Emmanuele Bassi * glib/tmpl/macros.sgml: Document the undefined behaviour of diff --git a/docs/reference/glib/tmpl/quarks.sgml b/docs/reference/glib/tmpl/quarks.sgml index 6803cde..c3b07d4 100644 --- a/docs/reference/glib/tmpl/quarks.sgml +++ b/docs/reference/glib/tmpl/quarks.sgml @@ -43,7 +43,8 @@ using strcmp(). -A GQuark is an integer which uniquely identifies a particular string. +A GQuark is a non-zero integer which uniquely identifies a particular string. +A GQuark value of zero is associated to %NULL. @@ -55,7 +56,7 @@ If the string does not currently have an associated #GQuark, a new @string: a string. -@Returns: the #GQuark identifying the string. +@Returns: the #GQuark identifying the string, or 0 if @string is %NULL. @@ -76,7 +77,7 @@ GTK+ theme engines). @string: a string. -@Returns: the #GQuark identifying the string. +@Returns: the #GQuark identifying the string, or 0 if @string is %NULL. @@ -90,8 +91,8 @@ Gets the string associated with the given #GQuark. -Gets the #GQuark associated with the given string, or 0 if the string has -no associated #GQuark. +Gets the #GQuark associated with the given string, or 0 if string is +%NULL or it has no associated #GQuark. If you want the GQuark to be created if it doesn't already exist, use @@ -99,8 +100,8 @@ g_quark_from_string() or g_quark_from_static_string(). @string: a string. -@Returns: the #GQuark associated with the string, or 0 if there is no -#GQuark associated with the string. +@Returns: the #GQuark associated with the string, or 0 if @string is +%NULL or there is no #GQuark associated with it. diff --git a/glib/gdataset.c b/glib/gdataset.c index cc2a5c7..fe6e4ed 100644 --- a/glib/gdataset.c +++ b/glib/gdataset.c @@ -635,7 +635,8 @@ g_quark_from_string (const gchar *string) { GQuark quark; - g_return_val_if_fail (string != NULL, 0); + if (!string) + return 0; G_LOCK (g_quark_global); quark = g_quark_from_string_internal (string, TRUE); @@ -649,7 +650,8 @@ g_quark_from_static_string (const gchar *string) { GQuark quark; - g_return_val_if_fail (string != NULL, 0); + if (!string) + return 0; G_LOCK (g_quark_global); quark = g_quark_from_string_internal (string, FALSE); -- 2.7.4