+2006-12-03 Ryan Lortie <desrt@desrt.ca>
+
+ * tests/hash-test.c (second_hash_test): fix memory leak, add a few
+ extra sanity tests.
+
2007-12-03 Matthias Clasen <mclasen@redhat.com>
* glib/gkeyfile.c: Don't call g_get_language_names() per-key.
crcinit ();
- h = g_hash_table_new (simple_hash ? one_hash : honeyman_hash,
- second_hash_cmp);
+ h = g_hash_table_new_full (simple_hash ? one_hash : honeyman_hash,
+ second_hash_cmp,
+ g_xfree, g_xfree);
g_assert (h != NULL);
for (i=0; i<20; i++)
{
sprintf (key, "%d", 3);
g_hash_table_remove (h, key);
+ g_assert (g_hash_table_size (h) == 19);
g_hash_table_foreach_remove (h, remove_even_foreach, NULL);
+ g_assert (g_hash_table_size (h) == 9);
g_hash_table_foreach (h, not_even_foreach, NULL);
for (i=0; i<20; i++)
{
- if ((i % 2) == 0 || i == 3)
- continue;
-
sprintf (key, "%d", i);
g_assert (atoi(key) == i);
found = g_hash_table_lookup_extended (h, key,
(gpointer)&orig_key,
(gpointer)&orig_val);
- g_assert (found);
+ if ((i % 2) == 0 || i == 3)
+ {
+ g_assert (!found);
+ continue;
+ }
- g_hash_table_remove (h, key);
+ g_assert (found);
g_assert (orig_key != NULL);
g_assert (strcmp (key, orig_key) == 0);
- g_free (orig_key);
g_assert (orig_val != NULL);
g_assert (strcmp (val, orig_val) == 0);
- g_free (orig_val);
}
g_hash_table_destroy (h);