summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2003-02-16 13:19:49 +0000
committerAlexander Larsson <alexl@redhat.com>2003-02-16 13:19:49 +0000
commit8925ff6d9870ccaab0feeb4f9af6e1f075d313ef (patch)
treeb44f3c31a826d8fa0f7711d7126741307470aae9
parentbf07fc88a330061c59186bf4a11218b5d51aec6f (diff)
2003-02-16 Alexander Larsson <alexl@redhat.com>
* dbus/dbus-hash.c (_dbus_hash_table_unref): Actually free keys and values when destroying hashtable.
-rw-r--r--ChangeLog5
-rw-r--r--dbus/dbus-hash.c28
2 files changed, 30 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index ec0bb118..29dcd4e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-02-16 Alexander Larsson <alexl@redhat.com>
+
+ * dbus/dbus-hash.c (_dbus_hash_table_unref):
+ Actually free keys and values when destroying hashtable.
+
2003-02-16 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-auth.c: (client_try_next_mechanism):
diff --git a/dbus/dbus-hash.c b/dbus/dbus-hash.c
index 8bac61a8..d7791d2a 100644
--- a/dbus/dbus-hash.c
+++ b/dbus/dbus-hash.c
@@ -236,6 +236,8 @@ static void remove_entry (DBusHashTable *table,
DBusHashEntry *entry);
static void free_entry (DBusHashTable *table,
DBusHashEntry *entry);
+static void free_entry_data (DBusHashTable *table,
+ DBusHashEntry *entry);
/** @} */
@@ -371,6 +373,20 @@ _dbus_hash_table_unref (DBusHashTable *table)
}
}
#else
+ DBusHashEntry *entry;
+ int i;
+
+ /* Free the entries in the table. */
+ for (i = 0; i < table->n_buckets; i++)
+ {
+ entry = table->buckets[i];
+ while (entry != NULL)
+ {
+ free_entry_data (table, entry);
+
+ entry = entry->next;
+ }
+ }
/* We can do this very quickly with memory pools ;-) */
_dbus_mem_pool_free (table->entry_pool);
#endif
@@ -394,14 +410,20 @@ alloc_entry (DBusHashTable *table)
}
static void
-free_entry (DBusHashTable *table,
- DBusHashEntry *entry)
+free_entry_data (DBusHashTable *table,
+ DBusHashEntry *entry)
{
if (table->free_key_function)
(* table->free_key_function) (entry->key);
if (table->free_value_function)
(* table->free_value_function) (entry->value);
-
+}
+
+static void
+free_entry (DBusHashTable *table,
+ DBusHashEntry *entry)
+{
+ free_entry_data (table, entry);
_dbus_mem_pool_dealloc (table->entry_pool, entry);
}