summaryrefslogtreecommitdiffstats
path: root/gettext-tools
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2005-10-07 11:29:05 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:12:53 +0200
commitcb0eac2f6599a31e25af1bc14b50f18f22b06103 (patch)
tree39a0264f04fc23e9d65388a5dddc64783724b4f5 /gettext-tools
parent2cd9afbab88b05391c2ed8d47e0327614c46d5f3 (diff)
downloadexternal_gettext-cb0eac2f6599a31e25af1bc14b50f18f22b06103.zip
external_gettext-cb0eac2f6599a31e25af1bc14b50f18f22b06103.tar.gz
external_gettext-cb0eac2f6599a31e25af1bc14b50f18f22b06103.tar.bz2
Make it possible for the hash value to point to the statically stored
hash key.
Diffstat (limited to 'gettext-tools')
-rw-r--r--gettext-tools/lib/ChangeLog5
-rw-r--r--gettext-tools/lib/hash.c11
-rw-r--r--gettext-tools/lib/hash.h11
-rw-r--r--gettext-tools/src/ChangeLog4
-rw-r--r--gettext-tools/src/message.c2
5 files changed, 22 insertions, 11 deletions
diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog
index dd0f192..a3b2782ae 100644
--- a/gettext-tools/lib/ChangeLog
+++ b/gettext-tools/lib/ChangeLog
@@ -1,5 +1,10 @@
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.
(hash_init): Renamed from init_hash.
(hash_destroy): Renamed from delete_hash.
diff --git a/gettext-tools/lib/hash.c b/gettext-tools/lib/hash.c
index 2a96210..21374f2 100644
--- a/gettext-tools/lib/hash.c
+++ b/gettext-tools/lib/hash.c
@@ -262,9 +262,10 @@ resize (hash_table *htab)
/* 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)
@@ -275,7 +276,7 @@ hash_insert_entry (hash_table *htab,
if (table[idx].used)
/* We don't want to overwrite the old value. */
- return -1;
+ return NULL;
else
{
/* An empty bucket has been found. */
@@ -284,7 +285,7 @@ hash_insert_entry (hash_table *htab,
if (100 * htab->filled > 75 * htab->size)
/* Table is filled more than 75%. Resize the table. */
resize (htab);
- return 0;
+ return keycopy;
}
}
diff --git a/gettext-tools/lib/hash.h b/gettext-tools/lib/hash.h
index 2e6ea52..e4653e5 100644
--- a/gettext-tools/lib/hash.h
+++ b/gettext-tools/lib/hash.h
@@ -50,11 +50,12 @@ extern int hash_find_entry (hash_table *htab,
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. */
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 5ae64f6..bb13df5 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,5 +1,9 @@
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,
message_list_hash_insert_entry, message_list_remove_if_not,
message_list_msgids_changed, message_list_search): Update.
diff --git a/gettext-tools/src/message.c b/gettext-tools/src/message.c
index b2b3010..0918e9f 100644
--- a/gettext-tools/src/message.c
+++ b/gettext-tools/src/message.c
@@ -276,7 +276,7 @@ message_list_hash_insert_entry (hash_table *htable, message_ty *mp)
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);