mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +01:00
gutils: use atomic pointers for g_prgname
The mutex is not necessary to guard a single pointer.
This commit is contained in:
parent
74502f51a6
commit
167deee94d
@ -1128,7 +1128,6 @@ g_get_host_name (void)
|
||||
return hostname;
|
||||
}
|
||||
|
||||
G_LOCK_DEFINE_STATIC (g_prgname);
|
||||
static const gchar *g_prgname = NULL; /* always a quark */
|
||||
|
||||
/**
|
||||
@ -1150,13 +1149,7 @@ static const gchar *g_prgname = NULL; /* always a quark */
|
||||
const gchar*
|
||||
g_get_prgname (void)
|
||||
{
|
||||
const gchar* retval;
|
||||
|
||||
G_LOCK (g_prgname);
|
||||
retval = g_prgname;
|
||||
G_UNLOCK (g_prgname);
|
||||
|
||||
return retval;
|
||||
return g_atomic_pointer_get (&g_prgname);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1179,10 +1172,8 @@ g_get_prgname (void)
|
||||
void
|
||||
g_set_prgname (const gchar *prgname)
|
||||
{
|
||||
GQuark qprgname = g_quark_from_string (prgname);
|
||||
G_LOCK (g_prgname);
|
||||
g_prgname = g_quark_to_string (qprgname);
|
||||
G_UNLOCK (g_prgname);
|
||||
prgname = g_intern_string (prgname);
|
||||
g_atomic_pointer_set (&g_prgname, prgname);
|
||||
}
|
||||
|
||||
G_LOCK_DEFINE_STATIC (g_application_name);
|
||||
|
Loading…
Reference in New Issue
Block a user