hash key.
+2005-10-03 Bruno Haible <bruno@clisp.org>
+
+ * hash.h (hash_insert_entry): Return a pointer instead of int.
+ * hash.c (hash_insert_entry): Return a pointer to the copy of the key.
+
2005-10-03 Bruno Haible <bruno@clisp.org>
* hash.h: Add comments everywhere.
/* Try to insert the pair (KEY[0..KEYLEN-1], DATA) in the hash table.
- Return 0 if successful, or -1 if there is already an entry with the given
- key. */
-int
+ Return non-NULL (more precisely, the address of the KEY inside the table's
+ memory pool) if successful, or NULL if there is already an entry with the
+ given key. */
+const void *
hash_insert_entry (hash_table *htab,
const void *key, size_t keylen,
void *data)
if (table[idx].used)
/* We don't want to overwrite the old value. */
- return -1;
+ return NULL;
else
{
/* An empty bucket has been found. */
if (100 * htab->filled > 75 * htab->size)
/* Table is filled more than 75%. Resize the table. */
resize (htab);
- return 0;
+ return keycopy;
}
}
void **result);
/* Try to insert the pair (KEY[0..KEYLEN-1], DATA) in the hash table.
- Return 0 if successful, or -1 if there is already an entry with the given
- key. */
-extern int hash_insert_entry (hash_table *htab,
- const void *key, size_t keylen,
- void *data);
+ Return non-NULL (more precisely, the address of the KEY inside the table's
+ memory pool) if successful, or NULL if there is already an entry with the
+ given key. */
+extern const void * hash_insert_entry (hash_table *htab,
+ const void *key, size_t keylen,
+ void *data);
/* Insert the pair (KEY[0..KEYLEN-1], DATA) in the hash table.
Return 0. */
+2005-10-03 Bruno Haible <bruno@clisp.org>
+
+ * message.c (message_list_hash_insert_entry): Update.
+
2005-10-03 Bruno Haible <bruno@clisp.org>
* message.c (message_list_alloc, message_list_free,
keylen = strlen (mp->msgid) + 1;
}
- found = hash_insert_entry (htable, key, keylen, mp);
+ found = (hash_insert_entry (htable, key, keylen, mp) == NULL);
if (mp->msgctxt != NULL)
freesa (alloced_key);