1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2025-05-30 17:30:07 +02:00

GTimeZone: don't add /etc/localtime to the cache

It may change.
This commit is contained in:
Ryan Lortie 2011-03-18 23:09:17 -04:00
parent 3d46c848c5
commit 29a074b87e

@ -132,25 +132,6 @@ struct _GTimeZone
G_LOCK_DEFINE_STATIC (time_zones); G_LOCK_DEFINE_STATIC (time_zones);
static GHashTable/*<string?, GTimeZone>*/ *time_zones; static GHashTable/*<string?, GTimeZone>*/ *time_zones;
static guint
g_str_hash0 (gconstpointer data)
{
return data ? g_str_hash (data) : 0;
}
static gboolean
g_str_equal0 (gconstpointer a,
gconstpointer b)
{
if (a == b)
return TRUE;
if (!a || !b)
return FALSE;
return g_str_equal (a, b);
}
/** /**
* g_time_zone_unref: * g_time_zone_unref:
* @tz: a #GTimeZone * @tz: a #GTimeZone
@ -165,10 +146,13 @@ g_time_zone_unref (GTimeZone *tz)
g_assert (tz->ref_count > 0); g_assert (tz->ref_count > 0);
if (g_atomic_int_dec_and_test (&tz->ref_count)) if (g_atomic_int_dec_and_test (&tz->ref_count))
{
if (tz->name != NULL)
{ {
G_LOCK(time_zones); G_LOCK(time_zones);
g_hash_table_remove (time_zones, tz->name); g_hash_table_remove (time_zones, tz->name);
G_UNLOCK(time_zones); G_UNLOCK(time_zones);
}
if (tz->zoneinfo) if (tz->zoneinfo)
g_buffer_unref (tz->zoneinfo); g_buffer_unref (tz->zoneinfo);
@ -345,10 +329,13 @@ g_time_zone_new (const gchar *identifier)
G_LOCK (time_zones); G_LOCK (time_zones);
if (time_zones == NULL) if (time_zones == NULL)
time_zones = g_hash_table_new (g_str_hash0, time_zones = g_hash_table_new (g_str_hash, g_str_equal);
g_str_equal0);
if (identifier)
tz = g_hash_table_lookup (time_zones, identifier); tz = g_hash_table_lookup (time_zones, identifier);
else
tz = NULL;
if (tz == NULL) if (tz == NULL)
{ {
tz = g_slice_new0 (GTimeZone); tz = g_slice_new0 (GTimeZone);
@ -412,6 +399,7 @@ g_time_zone_new (const gchar *identifier)
} }
} }
if (identifier)
g_hash_table_insert (time_zones, tz->name, tz); g_hash_table_insert (time_zones, tz->name, tz);
} }
g_atomic_int_inc (&tz->ref_count); g_atomic_int_inc (&tz->ref_count);