From 68a3c593b9e77b33614726363c7b6fd85d113021 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 18 Aug 2003 22:43:30 +0000 Subject: 2003-08-18 Havoc Pennington * dbus/dbus-hash.c (_dbus_hash_table_insert_two_strings): fix * dbus/dbus-message.c (_dbus_message_loader_queue_messages): fix dumb bug created earlier (wrong order of args to decode_header_data()) * tools/dbus-send.c: port * tools/dbus-print-message.c (print_message): port * test/data/*messages: port all messages over * dbus/dbus-message-builder.c: support including message type * bus/driver.c: port over * bus/dispatch.c: port over to new stuff * dbus/dbus-connection.c (_dbus_connection_new_for_transport): rename disconnect signal to "Disconnected" --- dbus/dbus-hash.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'dbus/dbus-hash.c') diff --git a/dbus/dbus-hash.c b/dbus/dbus-hash.c index f4547815..044dc534 100644 --- a/dbus/dbus-hash.c +++ b/dbus/dbus-hash.c @@ -1423,17 +1423,24 @@ _dbus_hash_table_insert_two_strings (DBusHashTable *table, char *key, void *value) { - DBusPreallocatedHash *preallocated; - + DBusHashEntry *entry; + _dbus_assert (table->key_type == DBUS_HASH_TWO_STRINGS); + + entry = (* table->find_function) (table, key, TRUE, NULL, NULL); - preallocated = _dbus_hash_table_preallocate_entry (table); - if (preallocated == NULL) - return FALSE; + if (entry == NULL) + return FALSE; /* no memory */ - _dbus_hash_table_insert_string_preallocated (table, preallocated, - key, value); + if (table->free_key_function && entry->key != key) + (* table->free_key_function) (entry->key); + + if (table->free_value_function && entry->value != value) + (* table->free_value_function) (entry->value); + entry->key = key; + entry->value = value; + return TRUE; } @@ -1811,8 +1818,8 @@ _dbus_hash_test (void) if (value == NULL) goto out; - if (!_dbus_hash_table_insert_string (table4, - key, value)) + if (!_dbus_hash_table_insert_two_strings (table4, + key, value)) goto out; _dbus_assert (count_entries (table1) == i + 1); @@ -1832,9 +1839,9 @@ _dbus_hash_test (void) _dbus_assert (value != NULL); _dbus_assert (strcmp (value, keys[i]) == 0); - value = _dbus_hash_table_lookup_ulong (table4, i); + value = _dbus_hash_table_lookup_two_strings (table4, keys[i]); _dbus_assert (value != NULL); - _dbus_assert (strcmp (value, keys[i]) == 0); + _dbus_assert (strcmp (value, "Value!") == 0); ++i; } -- cgit