pidgin: 0ed824d0: Use g_direct_hash/equal instead of g_int..

qulogic at pidgin.im qulogic at pidgin.im
Sun Feb 15 04:10:29 EST 2009


-----------------------------------------------------------------
Revision: 0ed824d0e7a548cb9a2fc4da692270475567d7d6
Ancestor: 5c1b1793e5a18e4e9272157a0d24d41c2d96647f
Author: qulogic at pidgin.im
Date: 2009-02-15T07:19:59
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/0ed824d0e7a548cb9a2fc4da692270475567d7d6

Modified files:
        libpurple/savedstatuses.c

ChangeLog: 

Use g_direct_hash/equal instead of g_int_hash/equal for the hash table that
holds the saved statuses. The effect is that this will take into account
the different size of time_t across 32-bit and 64-bit systems. There
should not be any side effects because it is only used at runtime for the
hash key, and all the important data is stored in the value.

This should stop any mysterious infinite loop problems on big-endian
systems which were trying to use the MSB of the time as a hash key.

Fixes #5887.

-------------- next part --------------
============================================================
--- libpurple/savedstatuses.c	5f842ca17975257f3af208f4125d43cb00d34d52
+++ libpurple/savedstatuses.c	a634a5dac266a10c73d730047c9b12db144c5963
@@ -148,11 +148,11 @@ set_creation_time(PurpleSavedStatus *sta
 	/* Avoid using 0 because it's an invalid hash key */
 	status->creation_time = creation_time != 0 ? creation_time : 1;
 
-	while (g_hash_table_lookup(creation_times, &status->creation_time) != NULL)
+	while (g_hash_table_lookup(creation_times, (gconstpointer)status->creation_time) != NULL)
 		status->creation_time++;
 
 	g_hash_table_insert(creation_times,
-						&status->creation_time,
+						(gpointer)status->creation_time,
 						status);
 }
 
@@ -217,7 +217,7 @@ remove_old_transient_statuses(void)
 				{
 					saved_statuses = g_list_remove(saved_statuses, saved_status);
 					creation_time = purple_savedstatus_get_creation_time(saved_status);
-					g_hash_table_remove(creation_times, &creation_time);
+					g_hash_table_remove(creation_times, (gconstpointer)creation_time);
 					free_saved_status(saved_status);
 				}
 			}
@@ -713,7 +713,7 @@ purple_savedstatus_delete_by_status(Purp
 
 	saved_statuses = g_list_remove(saved_statuses, status);
 	creation_time = purple_savedstatus_get_creation_time(status);
-	g_hash_table_remove(creation_times, &creation_time);
+	g_hash_table_remove(creation_times, (gconstpointer)creation_time);
 	free_saved_status(status);
 
 	schedule_save();
@@ -801,13 +801,13 @@ purple_savedstatus_get_default()
 PurpleSavedStatus *
 purple_savedstatus_get_default()
 {
-	int creation_time;
+	time_t creation_time;
 	PurpleSavedStatus *saved_status = NULL;
 
 	creation_time = purple_prefs_get_int("/purple/savedstatus/default");
 
 	if (creation_time != 0)
-		saved_status = g_hash_table_lookup(creation_times, &creation_time);
+		saved_status = g_hash_table_lookup(creation_times, (gconstpointer)creation_time);
 
 	if (saved_status == NULL)
 	{
@@ -828,13 +828,13 @@ purple_savedstatus_get_idleaway()
 PurpleSavedStatus *
 purple_savedstatus_get_idleaway()
 {
-	int creation_time;
+	time_t creation_time;
 	PurpleSavedStatus *saved_status = NULL;
 
 	creation_time = purple_prefs_get_int("/purple/savedstatus/idleaway");
 
 	if (creation_time != 0)
-		saved_status = g_hash_table_lookup(creation_times, &creation_time);
+		saved_status = g_hash_table_lookup(creation_times, (gconstpointer)creation_time);
 
 	if (saved_status == NULL)
 	{
@@ -907,13 +907,13 @@ purple_savedstatus_get_startup()
 PurpleSavedStatus *
 purple_savedstatus_get_startup()
 {
-	int creation_time;
+	time_t creation_time;
 	PurpleSavedStatus *saved_status = NULL;
 
 	creation_time = purple_prefs_get_int("/purple/savedstatus/startup");
 
 	if (creation_time != 0)
-		saved_status = g_hash_table_lookup(creation_times, &creation_time);
+		saved_status = g_hash_table_lookup(creation_times, (gconstpointer)creation_time);
 
 	if (saved_status == NULL)
 	{
@@ -1187,7 +1187,7 @@ purple_savedstatuses_init(void)
 {
 	void *handle = purple_savedstatuses_get_handle();
 
-	creation_times = g_hash_table_new(g_int_hash, g_int_equal);
+	creation_times = g_hash_table_new(g_direct_hash, g_direct_equal);
 
 	/*
 	 * Using 0 as the creation_time is a special case.


More information about the Commits mailing list