mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +01:00
Fix thread safety of g_get_language_names()
https://bugzilla.gnome.org/show_bug.cgi?id=748474
This commit is contained in:
parent
f55a5b69b7
commit
41888493f0
@ -228,17 +228,14 @@ g_get_codeset (void)
|
|||||||
|
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
|
|
||||||
static GHashTable *alias_table = NULL;
|
|
||||||
|
|
||||||
/* read an alias file for the locales */
|
/* read an alias file for the locales */
|
||||||
static void
|
static void
|
||||||
read_aliases (gchar *file)
|
read_aliases (gchar *file,
|
||||||
|
GHashTable *alias_table)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
if (!alias_table)
|
|
||||||
alias_table = g_hash_table_new (g_str_hash, g_str_equal);
|
|
||||||
fp = fopen (file,"r");
|
fp = fopen (file,"r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return;
|
return;
|
||||||
@ -289,11 +286,16 @@ static char *
|
|||||||
unalias_lang (char *lang)
|
unalias_lang (char *lang)
|
||||||
{
|
{
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
|
static GHashTable *alias_table = NULL;
|
||||||
char *p;
|
char *p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!alias_table)
|
if (g_once_init_enter (&alias_table))
|
||||||
read_aliases ("/usr/share/locale/locale.alias");
|
{
|
||||||
|
GHashTable *table = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
read_aliases ("/usr/share/locale/locale.alias", table);
|
||||||
|
g_once_init_leave (&alias_table, table);
|
||||||
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((p = g_hash_table_lookup (alias_table, lang)) && (strcmp (p, lang) != 0))
|
while ((p = g_hash_table_lookup (alias_table, lang)) && (strcmp (p, lang) != 0))
|
||||||
|
Loading…
Reference in New Issue
Block a user