[gnome-db] gda_parameter_list_clear()
- From: Laurent Sansonetti <lrz gnome org>
- To: Gnome-db list <gnome-db-list gnome org>
- Subject: [gnome-db] gda_parameter_list_clear()
- Date: Sat, 29 Nov 2003 20:11:08 +0000
Hi,
I found a bug in gda_parameter_list_clear(). Parameters were not
removed from the hash table (they were just freed).
Attached is a patch + a test case I used to find the bug.
Cheers,
--
Laurent
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/ChangeLog,v
retrieving revision 1.595
diff -u -r1.595 ChangeLog
--- ChangeLog 29 Nov 2003 16:25:04 -0000 1.595
+++ ChangeLog 29 Nov 2003 17:12:20 -0000
@@ -1,5 +1,8 @@
2003-11-29 Laurent Sansonetti <lrz gnome org>
+ * libgda/gda-parameter.c (gda_parameter_list_clear):
+ Parameters were not removed from the hash table (just freed).
+
* providers/bdb/*.c:
Fixes compilation problems with Berkeley DB 4.x.
Index: libgda/gda-parameter.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-parameter.c,v
retrieving revision 1.26
diff -u -r1.26 gda-parameter.c
--- libgda/gda-parameter.c 21 Nov 2003 21:12:21 -0000 1.26
+++ libgda/gda-parameter.c 29 Nov 2003 17:12:21 -0000
@@ -58,11 +58,12 @@
* Private functions
*/
-static void
+static gboolean
free_hash_param (gpointer key, gpointer value, gpointer user_data)
{
g_free (key);
gda_parameter_free ((GdaParameter *) value);
+ return TRUE;
}
/**
@@ -433,7 +434,7 @@
gda_parameter_list_clear (GdaParameterList *plist)
{
g_return_if_fail (plist != NULL);
- g_hash_table_foreach_remove (plist->hash, (GHRFunc) free_hash_param, NULL);
+ g_hash_table_foreach_remove (plist->hash, free_hash_param, NULL);
}
/**
#include <libgda/libgda.h>
int
main (int argc, char **argv)
{
GdaParameterList *list = gda_parameter_list_new ();
g_assert (list != NULL);
gda_parameter_list_add_parameter (list,
gda_parameter_new_string ("foo",
"bar"));
g_assert (gda_parameter_list_get_length (list) == 1);
gda_parameter_list_clear (list);
g_assert (gda_parameter_list_get_length (list) == 0);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]