[pango] Make static data thread safe in pango-utils.c
- From: Behdad Esfahbod <behdad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] Make static data thread safe in pango-utils.c
- Date: Tue, 28 Aug 2012 04:33:22 +0000 (UTC)
commit b47c2247e398bdb56f929a1144d6cc0b995233b0
Author: Alessandro Pignotti <a pignotti sssup it>
Date: Wed May 18 19:49:51 2011 +0200
Make static data thread safe in pango-utils.c
pango/pango-utils.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/pango/pango-utils.c b/pango/pango-utils.c
index dbf0602..c753683 100644
--- a/pango/pango-utils.c
+++ b/pango/pango-utils.c
@@ -719,19 +719,21 @@ pango_get_sysconf_subdirectory (void)
{
static const gchar *result = NULL;
- if (result == NULL)
+ if (g_once_init_enter ((gsize*)&result))
{
+ gchar *tmp_result = NULL;
#ifdef G_OS_WIN32
gchar *root = g_win32_get_package_installation_directory_of_module (pango_dll);
- result = g_build_filename (root, "etc\\pango", NULL);
+ tmp_result = g_build_filename (root, "etc\\pango", NULL);
g_free (root);
#else
const char *sysconfdir = g_getenv ("PANGO_SYSCONFDIR");
if (sysconfdir != NULL)
- result = g_build_filename (sysconfdir, "pango", NULL);
+ tmp_result = g_build_filename (sysconfdir, "pango", NULL);
else
- result = SYSCONFDIR "/pango";
+ tmp_result = SYSCONFDIR "/pango";
#endif
+ g_once_init_leave((gsize*)&result, (gsize)tmp_result);
}
return result;
}
@@ -752,25 +754,27 @@ pango_get_lib_subdirectory (void)
{
static const gchar *result = NULL;
- if (result == NULL)
+ if (g_once_init_enter ((gsize*)&result))
{
+ gchar *tmp_result = NULL;
#ifdef G_OS_WIN32
gchar *root = g_win32_get_package_installation_directory_of_module (pango_dll);
/* If we are running against an uninstalled copy of the Pango DLL,
* use the compile-time installation prefix.
*/
if (g_str_has_suffix (root, "\\.libs"))
- result = g_strdup (LIBDIR "/pango");
+ tmp_result = g_strdup (LIBDIR "/pango");
else
- result = g_build_filename (root, "lib\\pango", NULL);
+ tmp_result = g_build_filename (root, "lib\\pango", NULL);
g_free (root);
#else
const char *libdir = g_getenv ("PANGO_LIBDIR");
if (libdir != NULL)
- result = g_build_filename (libdir, "pango", NULL);
+ tmp_result = g_build_filename (libdir, "pango", NULL);
else
- result = LIBDIR "/pango";
+ tmp_result = LIBDIR "/pango";
#endif
+ g_once_init_leave((gsize*)&result, (gsize)tmp_result);
}
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]