diff libpurple/plugins/perl/common/BuddyList.xs @ 30487:a2d5bafdbea9

perl: Fix chat-related functions. Purple::BuddyList::Chat::new needs to copy the strings, since the GHashTable is long-listing. The serv_join_chat wrapper needs to free the hash table, since that one isn't owned by the prpl.
author Paul Aurich <paul@darkrain42.org>
date Sun, 05 Sep 2010 01:30:56 +0000
parents 6e1967b0f90b
children 0149f914962e
line wrap: on
line diff
--- a/libpurple/plugins/perl/common/BuddyList.xs	Sat Sep 04 17:47:46 2010 +0000
+++ b/libpurple/plugins/perl/common/BuddyList.xs	Sun Sep 05 01:30:56 2010 +0000
@@ -345,14 +345,14 @@
 	char *t_key, *t_value;
 CODE:
 	t_HV =  (HV *)SvRV(components);
-	t_GHash = g_hash_table_new(g_str_hash, g_str_equal);
+	t_GHash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
 
 	for (t_HE = hv_iternext(t_HV); t_HE != NULL; t_HE = hv_iternext(t_HV) ) {
 		t_key = hv_iterkey(t_HE, &len);
 		t_SV = *hv_fetch(t_HV, t_key, len, 0);
 		t_value = SvPVutf8_nolen(t_SV);
 
-		g_hash_table_insert(t_GHash, t_key, t_value);
+		g_hash_table_insert(t_GHash, g_strdup(t_key), g_strdup(t_value));
 	}
 
 	RETVAL = purple_chat_new(account, alias, t_GHash);