/pidgin/main: b495bcb42c5c: Use a GQuark to generate a constant ...

Daniel Atallah datallah at pidgin.im
Sun Feb 24 12:21:40 EST 2013


Changeset: b495bcb42c5c96e6582ff458f44b4ad4693844b6
Author:	 Daniel Atallah <datallah at pidgin.im>
Date:	 2013-02-24 12:21 -0500
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/b495bcb42c5c

Description:

Use a GQuark to generate a constant pointer instead of relying on undefined compiler behavior

diffstat:

 pidgin/gtksourceundomanager.c |  11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diffs (22 lines):

diff --git a/pidgin/gtksourceundomanager.c b/pidgin/gtksourceundomanager.c
--- a/pidgin/gtksourceundomanager.c
+++ b/pidgin/gtksourceundomanager.c
@@ -100,8 +100,17 @@ struct _GtkSourceUndoAction
 	guint modified  : 1;
 };
 
+/* G_DEFINE_QUARK requires Glib 2.34 */
+static gpointer INVALID_quark(void) {
+	static volatile gsize g_define_quark__volatile = 0;
+	if (g_once_init_enter (&g_define_quark__volatile)) {
+		GQuark g_define_quark = g_quark_from_string ("IA");
+		g_once_init_leave (&g_define_quark__volatile, g_define_quark);
+	}
+	return GSIZE_TO_POINTER(g_define_quark__volatile);
+}
 /* INVALID is a pointer to an invalid action */
-#define INVALID ((void *) "IA")
+#define INVALID INVALID_quark()
 
 struct _GtkSourceUndoManagerPrivate
 {



More information about the Commits mailing list