G_LOCK_DEFINE_STATIC (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:
* @tz: a #GTimeZone
if (g_atomic_int_dec_and_test (&tz->ref_count))
{
- G_LOCK(time_zones);
- g_hash_table_remove (time_zones, tz->name);
- G_UNLOCK(time_zones);
+ if (tz->name != NULL)
+ {
+ G_LOCK(time_zones);
+ g_hash_table_remove (time_zones, tz->name);
+ G_UNLOCK(time_zones);
+ }
if (tz->zoneinfo)
g_buffer_unref (tz->zoneinfo);
G_LOCK (time_zones);
if (time_zones == NULL)
- time_zones = g_hash_table_new (g_str_hash0,
- g_str_equal0);
+ time_zones = g_hash_table_new (g_str_hash, g_str_equal);
+
+ if (identifier)
+ tz = g_hash_table_lookup (time_zones, identifier);
+ else
+ tz = NULL;
- tz = g_hash_table_lookup (time_zones, identifier);
if (tz == NULL)
{
tz = g_slice_new0 (GTimeZone);
}
}
- g_hash_table_insert (time_zones, tz->name, tz);
+ if (identifier)
+ g_hash_table_insert (time_zones, tz->name, tz);
}
g_atomic_int_inc (&tz->ref_count);
G_UNLOCK (time_zones);