console/libgnt/gntutils.c

changeset 15365
5a83efd6955d
parent 15220
fc8b223f4b75
child 20472
6a6d2ef151e6
equal deleted inserted replaced
15364:ad151a58e863 15365:5a83efd6955d
103 start = end; 103 start = end;
104 } 104 }
105 return g_string_free(str, FALSE); 105 return g_string_free(str, FALSE);
106 } 106 }
107 107
108 struct duplicate_fns
109 {
110 GDupFunc key_dup;
111 GDupFunc value_dup;
112 GHashTable *table;
113 };
114
108 static void 115 static void
109 duplicate_values(gpointer key, gpointer value, gpointer data) 116 duplicate_values(gpointer key, gpointer value, gpointer data)
110 { 117 {
111 g_hash_table_insert(data, key, value); 118 struct duplicate_fns *fns = data;
119 g_hash_table_insert(fns->table, fns->key_dup ? fns->key_dup(key) : key,
120 fns->value_dup ? fns->value_dup(value) : value);
112 } 121 }
113 122
114 GHashTable *g_hash_table_duplicate(GHashTable *src, GHashFunc hash, 123 GHashTable *g_hash_table_duplicate(GHashTable *src, GHashFunc hash,
115 GEqualFunc equal, GDestroyNotify key_d, GDestroyNotify value_d) 124 GEqualFunc equal, GDestroyNotify key_d, GDestroyNotify value_d,
125 GDupFunc key_dup, GDupFunc value_dup)
116 { 126 {
117 GHashTable *dest = g_hash_table_new_full(hash, equal, key_d, value_d); 127 GHashTable *dest = g_hash_table_new_full(hash, equal, key_d, value_d);
118 g_hash_table_foreach(src, duplicate_values, dest); 128 struct duplicate_fns fns = {key_dup, value_dup, dest};
129 g_hash_table_foreach(src, duplicate_values, &fns);
119 return dest; 130 return dest;
120 } 131 }
121 132
122 gboolean gnt_boolean_handled_accumulator(GSignalInvocationHint *ihint, 133 gboolean gnt_boolean_handled_accumulator(GSignalInvocationHint *ihint,
123 GValue *return_accu, 134 GValue *return_accu,

mercurial