[glib] GRegex: fix thread-unsafe initialiser code
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GRegex: fix thread-unsafe initialiser code
- Date: Sat, 10 Sep 2011 00:26:54 +0000 (UTC)
commit 066c7b81211fe203d2f7a4c7556c05bd53293097
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Sep 9 19:54:06 2011 -0400
GRegex: fix thread-unsafe initialiser code
glib/gregex.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/glib/gregex.c b/glib/gregex.c
index d07036b..74a2b0f 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -1187,7 +1187,7 @@ g_regex_new (const gchar *pattern,
gint erroffset;
gint errcode;
gboolean optimize = FALSE;
- static gboolean initialized = FALSE;
+ static gsize initialised;
unsigned long int pcre_compile_options;
g_return_val_if_fail (pattern != NULL, NULL);
@@ -1195,7 +1195,7 @@ g_regex_new (const gchar *pattern,
g_return_val_if_fail ((compile_options & ~G_REGEX_COMPILE_MASK) == 0, NULL);
g_return_val_if_fail ((match_options & ~G_REGEX_MATCH_MASK) == 0, NULL);
- if (!initialized)
+ if (g_once_init_enter (&initialised))
{
gint support;
const gchar *msg;
@@ -1218,7 +1218,7 @@ g_regex_new (const gchar *pattern,
return NULL;
}
- initialized = TRUE;
+ g_once_init_leave (&initialised, TRUE);
}
/* G_REGEX_OPTIMIZE has the same numeric value of PCRE_NO_UTF8_CHECK,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]