mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +01:00
Move the body of the big if... (g_get_any_init_do): ... to this new
2005-08-16 Stepan Kasal <kasal@ucw.cz> * glib/gutils.c (g_get_any_init): Move the body of the big if... (g_get_any_init_do): ... to this new function. (g_get_any_init): Declare as inline. (g_get_any_init_locked): New inline function, does the locking. Make use of these two throughout the code.
This commit is contained in:
parent
56a63c1568
commit
63828e25ec
@ -1,3 +1,11 @@
|
||||
2005-08-16 Stepan Kasal <kasal@ucw.cz>
|
||||
|
||||
* glib/gutils.c (g_get_any_init): Move the body of the big if...
|
||||
(g_get_any_init_do): ... to this new function.
|
||||
(g_get_any_init): Declare as inline.
|
||||
(g_get_any_init_locked): New inline function, does the locking.
|
||||
Make use of these two throughout the code.
|
||||
|
||||
2005-08-15 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gbacktrace.c (g_on_error_stack_trace): Wait for
|
||||
|
@ -1,3 +1,11 @@
|
||||
2005-08-16 Stepan Kasal <kasal@ucw.cz>
|
||||
|
||||
* glib/gutils.c (g_get_any_init): Move the body of the big if...
|
||||
(g_get_any_init_do): ... to this new function.
|
||||
(g_get_any_init): Declare as inline.
|
||||
(g_get_any_init_locked): New inline function, does the locking.
|
||||
Make use of these two throughout the code.
|
||||
|
||||
2005-08-15 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gbacktrace.c (g_on_error_stack_trace): Wait for
|
||||
|
@ -1,3 +1,11 @@
|
||||
2005-08-16 Stepan Kasal <kasal@ucw.cz>
|
||||
|
||||
* glib/gutils.c (g_get_any_init): Move the body of the big if...
|
||||
(g_get_any_init_do): ... to this new function.
|
||||
(g_get_any_init): Declare as inline.
|
||||
(g_get_any_init_locked): New inline function, does the locking.
|
||||
Make use of these two throughout the code.
|
||||
|
||||
2005-08-15 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gbacktrace.c (g_on_error_stack_trace): Wait for
|
||||
|
@ -1,3 +1,11 @@
|
||||
2005-08-16 Stepan Kasal <kasal@ucw.cz>
|
||||
|
||||
* glib/gutils.c (g_get_any_init): Move the body of the big if...
|
||||
(g_get_any_init_do): ... to this new function.
|
||||
(g_get_any_init): Declare as inline.
|
||||
(g_get_any_init_locked): New inline function, does the locking.
|
||||
Make use of these two throughout the code.
|
||||
|
||||
2005-08-15 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gbacktrace.c (g_on_error_stack_trace): Wait for
|
||||
|
@ -1441,9 +1441,7 @@ get_windows_directory_root (void)
|
||||
|
||||
/* HOLDS: g_utils_global_lock */
|
||||
static void
|
||||
g_get_any_init (void)
|
||||
{
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init_do (void)
|
||||
{
|
||||
gchar hostname[100];
|
||||
|
||||
@ -1655,21 +1653,15 @@ g_get_any_init (void)
|
||||
if (!g_real_name)
|
||||
g_real_name = g_strdup ("Unknown");
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
if (gethostname (hostname, sizeof (hostname)) == -1)
|
||||
g_host_name = g_strdup ("localhost");
|
||||
else
|
||||
g_host_name = g_strdup (hostname);
|
||||
#else
|
||||
{
|
||||
#ifndef G_OS_WIN32
|
||||
gboolean hostname_fail = (gethostname (hostname, sizeof (hostname)) == -1);
|
||||
#else
|
||||
DWORD size = sizeof (hostname);
|
||||
|
||||
if (!GetComputerName (hostname, &size))
|
||||
g_host_name = g_strdup ("localhost");
|
||||
else
|
||||
g_host_name = g_strdup (hostname);
|
||||
}
|
||||
gboolean hostname_fail = (!GetComputerName (hostname, &size));
|
||||
#endif
|
||||
g_host_name = g_strdup (hostname_fail ? "localhost" : hostname);
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
g_tmp_dir_cp = g_locale_from_utf8 (g_tmp_dir, -1, NULL, NULL, NULL);
|
||||
@ -1692,8 +1684,23 @@ g_get_any_init (void)
|
||||
g_home_dir_cp = NULL;
|
||||
#endif /* G_OS_WIN32 */
|
||||
}
|
||||
|
||||
static inline void
|
||||
g_get_any_init (void)
|
||||
{
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init_do ();
|
||||
}
|
||||
|
||||
static inline void
|
||||
g_get_any_init_locked (void)
|
||||
{
|
||||
G_LOCK (g_utils_global);
|
||||
g_get_any_init ();
|
||||
G_UNLOCK (g_utils_global);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* g_get_user_name:
|
||||
*
|
||||
@ -1707,11 +1714,7 @@ g_get_any_init (void)
|
||||
G_CONST_RETURN gchar*
|
||||
g_get_user_name (void)
|
||||
{
|
||||
G_LOCK (g_utils_global);
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
G_UNLOCK (g_utils_global);
|
||||
|
||||
g_get_any_init_locked ();
|
||||
return g_user_name;
|
||||
}
|
||||
|
||||
@ -1729,11 +1732,7 @@ g_get_user_name (void)
|
||||
G_CONST_RETURN gchar*
|
||||
g_get_real_name (void)
|
||||
{
|
||||
G_LOCK (g_utils_global);
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
G_UNLOCK (g_utils_global);
|
||||
|
||||
g_get_any_init_locked ();
|
||||
return g_real_name;
|
||||
}
|
||||
|
||||
@ -1751,11 +1750,7 @@ g_get_real_name (void)
|
||||
G_CONST_RETURN gchar*
|
||||
g_get_home_dir (void)
|
||||
{
|
||||
G_LOCK (g_utils_global);
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
G_UNLOCK (g_utils_global);
|
||||
|
||||
g_get_any_init_locked ();
|
||||
return g_home_dir;
|
||||
}
|
||||
|
||||
@ -1774,11 +1769,7 @@ g_get_home_dir (void)
|
||||
G_CONST_RETURN gchar*
|
||||
g_get_tmp_dir (void)
|
||||
{
|
||||
G_LOCK (g_utils_global);
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
G_UNLOCK (g_utils_global);
|
||||
|
||||
g_get_any_init_locked ();
|
||||
return g_tmp_dir;
|
||||
}
|
||||
|
||||
@ -1805,11 +1796,7 @@ g_get_tmp_dir (void)
|
||||
const gchar *
|
||||
g_get_host_name (void)
|
||||
{
|
||||
G_LOCK (g_utils_global);
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
G_UNLOCK (g_utils_global);
|
||||
|
||||
g_get_any_init_locked ();
|
||||
return g_host_name;
|
||||
}
|
||||
|
||||
@ -1988,7 +1975,6 @@ g_get_user_data_dir (void)
|
||||
#endif
|
||||
if (!data_dir || !data_dir[0])
|
||||
{
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
|
||||
if (g_home_dir)
|
||||
@ -2042,7 +2028,6 @@ g_get_user_config_dir (void)
|
||||
#endif
|
||||
if (!config_dir || !config_dir[0])
|
||||
{
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
|
||||
if (g_home_dir)
|
||||
@ -2093,7 +2078,6 @@ g_get_user_cache_dir (void)
|
||||
#endif
|
||||
if (!cache_dir || !cache_dir[0])
|
||||
{
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
|
||||
if (g_home_dir)
|
||||
@ -2991,11 +2975,7 @@ g_unsetenv (const gchar *variable)
|
||||
G_CONST_RETURN gchar*
|
||||
g_get_user_name (void)
|
||||
{
|
||||
G_LOCK (g_utils_global);
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
G_UNLOCK (g_utils_global);
|
||||
|
||||
g_get_any_init_locked ();
|
||||
return g_user_name_cp;
|
||||
}
|
||||
|
||||
@ -3004,11 +2984,7 @@ g_get_user_name (void)
|
||||
G_CONST_RETURN gchar*
|
||||
g_get_real_name (void)
|
||||
{
|
||||
G_LOCK (g_utils_global);
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
G_UNLOCK (g_utils_global);
|
||||
|
||||
g_get_any_init_locked ();
|
||||
return g_real_name_cp;
|
||||
}
|
||||
|
||||
@ -3017,11 +2993,7 @@ g_get_real_name (void)
|
||||
G_CONST_RETURN gchar*
|
||||
g_get_home_dir (void)
|
||||
{
|
||||
G_LOCK (g_utils_global);
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
G_UNLOCK (g_utils_global);
|
||||
|
||||
g_get_any_init_locked ();
|
||||
return g_home_dir_cp;
|
||||
}
|
||||
|
||||
@ -3030,11 +3002,7 @@ g_get_home_dir (void)
|
||||
G_CONST_RETURN gchar*
|
||||
g_get_tmp_dir (void)
|
||||
{
|
||||
G_LOCK (g_utils_global);
|
||||
if (!g_tmp_dir)
|
||||
g_get_any_init ();
|
||||
G_UNLOCK (g_utils_global);
|
||||
|
||||
g_get_any_init_locked ();
|
||||
return g_tmp_dir_cp;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user