Commit 935e9f0b authored by Bruno Haible's avatar Bruno Haible

Avoid using the variable name 'index' for two completely different things.

parent 33e26f50
2006-10-10 Bruno Haible <bruno@clisp.org>
Fix a gcc -Wshadow warning.
* lib/gl_anyhash_list2.h (hash_resize): Rename local variable 'index'
to 'bucket'.
* lib/gl_anylinked_list2.h (gl_linked_search_from_to,
gl_linked_indexof_from_to): Likewise.
* lib/gl_linkedhash_list.c (add_to_bucket, remove_from_bucket):
Likewise.
* lib/gl_anytreehash_list1.h (add_to_bucket, remove_from_bucket):
Likewise.
* lib/gl_anytreehash_list2.h (gl_tree_search_from_to): Likewise.
Reported by Eric Blake.
2006-10-09 Paul Eggert <eggert@cs.ucla.edu>
* lib/filemode.h [HAVE_DECL_STRMODE]: Include unistd.h too,
......
......@@ -113,9 +113,9 @@ hash_resize (gl_list_t list, size_t estimate)
{
gl_hash_entry_t next = node->hash_next;
/* Add the entry to the new table. */
size_t index = node->hashcode % new_size;
node->hash_next = new_table[index];
new_table[index] = node;
size_t bucket = node->hashcode % new_size;
node->hash_next = new_table[bucket];
new_table[bucket] = node;
node = next;
}
......
......@@ -229,7 +229,7 @@ gl_linked_search_from_to (gl_list_t list, size_t start_index, size_t end_index,
(list->base.hashcode_fn != NULL
? list->base.hashcode_fn (elt)
: (size_t)(uintptr_t) elt);
size_t index = hashcode % list->table_size;
size_t bucket = hashcode % list->table_size;
gl_listelement_equals_fn equals = list->base.equals_fn;
if (!list->base.allow_duplicates)
......@@ -238,7 +238,7 @@ gl_linked_search_from_to (gl_list_t list, size_t start_index, size_t end_index,
gl_list_node_t found = NULL;
gl_list_node_t node;
for (node = (gl_list_node_t) list->table[index];
for (node = (gl_list_node_t) list->table[bucket];
node != NULL;
node = (gl_list_node_t) node->h.hash_next)
if (node->h.hashcode == hashcode
......@@ -279,7 +279,7 @@ gl_linked_search_from_to (gl_list_t list, size_t start_index, size_t end_index,
gl_list_node_t first_match = NULL;
gl_list_node_t node;
for (node = (gl_list_node_t) list->table[index];
for (node = (gl_list_node_t) list->table[bucket];
node != NULL;
node = (gl_list_node_t) node->h.hash_next)
if (node->h.hashcode == hashcode
......@@ -385,7 +385,7 @@ gl_linked_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index,
(list->base.hashcode_fn != NULL
? list->base.hashcode_fn (elt)
: (size_t)(uintptr_t) elt);
size_t index = hashcode % list->table_size;
size_t bucket = hashcode % list->table_size;
gl_listelement_equals_fn equals = list->base.equals_fn;
gl_list_node_t node;
......@@ -393,7 +393,7 @@ gl_linked_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index,
if (!list->base.allow_duplicates)
{
/* Look for the first match in the hash bucket. */
for (node = (gl_list_node_t) list->table[index];
for (node = (gl_list_node_t) list->table[bucket];
node != NULL;
node = (gl_list_node_t) node->h.hash_next)
if (node->h.hashcode == hashcode
......@@ -408,7 +408,7 @@ gl_linked_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index,
bool multiple_matches = false;
gl_list_node_t first_match = NULL;
for (node = (gl_list_node_t) list->table[index];
for (node = (gl_list_node_t) list->table[bucket];
node != NULL;
node = (gl_list_node_t) node->h.hash_next)
if (node->h.hashcode == hashcode
......
......@@ -109,7 +109,7 @@ gl_oset_first (gl_oset_t set)
static void
add_to_bucket (gl_list_t list, gl_list_node_t new_node)
{
size_t index = new_node->h.hashcode % list->table_size;
size_t bucket = new_node->h.hashcode % list->table_size;
/* If no duplicates are allowed, multiple nodes are not needed. */
if (list->base.allow_duplicates)
......@@ -119,7 +119,7 @@ add_to_bucket (gl_list_t list, gl_list_node_t new_node)
gl_listelement_equals_fn equals = list->base.equals_fn;
gl_hash_entry_t *entryp;
for (entryp = &list->table[index]; *entryp != NULL; entryp = &(*entryp)->hash_next)
for (entryp = &list->table[bucket]; *entryp != NULL; entryp = &(*entryp)->hash_next)
{
gl_hash_entry_t entry = *entryp;
......@@ -171,8 +171,8 @@ add_to_bucket (gl_list_t list, gl_list_node_t new_node)
}
}
/* If no duplicates are allowed, multiple nodes are not needed. */
new_node->h.hash_next = list->table[index];
list->table[index] = &new_node->h;
new_node->h.hash_next = list->table[bucket];
list->table[bucket] = &new_node->h;
}
/* Remove a node from the hash table structure.
......@@ -184,7 +184,7 @@ add_to_bucket (gl_list_t list, gl_list_node_t new_node)
static void
remove_from_bucket (gl_list_t list, gl_list_node_t old_node)
{
size_t index = old_node->h.hashcode % list->table_size;
size_t bucket = old_node->h.hashcode % list->table_size;
if (list->base.allow_duplicates)
{
......@@ -193,7 +193,7 @@ remove_from_bucket (gl_list_t list, gl_list_node_t old_node)
gl_listelement_equals_fn equals = list->base.equals_fn;
gl_hash_entry_t *entryp;
for (entryp = &list->table[index]; ; entryp = &(*entryp)->hash_next)
for (entryp = &list->table[bucket]; ; entryp = &(*entryp)->hash_next)
{
gl_hash_entry_t entry = *entryp;
......@@ -239,7 +239,7 @@ remove_from_bucket (gl_list_t list, gl_list_node_t old_node)
/* If no duplicates are allowed, multiple nodes are not needed. */
gl_hash_entry_t *entryp;
for (entryp = &list->table[index]; ; entryp = &(*entryp)->hash_next)
for (entryp = &list->table[bucket]; ; entryp = &(*entryp)->hash_next)
{
if (*entryp == &old_node->h)
{
......
......@@ -31,13 +31,13 @@ gl_tree_search_from_to (gl_list_t list, size_t start_index, size_t end_index,
(list->base.hashcode_fn != NULL
? list->base.hashcode_fn (elt)
: (size_t)(uintptr_t) elt);
size_t index = hashcode % list->table_size;
size_t bucket = hashcode % list->table_size;
gl_listelement_equals_fn equals = list->base.equals_fn;
gl_hash_entry_t entry;
if (list->base.allow_duplicates)
{
for (entry = list->table[index]; entry != NULL; entry = entry->hash_next)
for (entry = list->table[bucket]; entry != NULL; entry = entry->hash_next)
if (entry->hashcode == hashcode)
{
if (((struct gl_multiple_nodes *) entry)->magic == MULTIPLE_NODES_MAGIC)
......@@ -102,7 +102,7 @@ gl_tree_search_from_to (gl_list_t list, size_t start_index, size_t end_index,
else
{
/* If no duplicates are allowed, multiple nodes are not needed. */
for (entry = list->table[index]; entry != NULL; entry = entry->hash_next)
for (entry = list->table[bucket]; entry != NULL; entry = entry->hash_next)
if (entry->hashcode == hashcode)
{
gl_list_node_t node = (struct gl_list_node_impl *) entry;
......
......@@ -58,20 +58,20 @@ hash_resize_after_add (gl_list_t list)
static inline void
add_to_bucket (gl_list_t list, gl_list_node_t node)
{
size_t index = node->h.hashcode % list->table_size;
size_t bucket = node->h.hashcode % list->table_size;
node->h.hash_next = list->table[index];
list->table[index] = &node->h;
node->h.hash_next = list->table[bucket];
list->table[bucket] = &node->h;
}
/* Remove a node from the hash table structure. */
static inline void
remove_from_bucket (gl_list_t list, gl_list_node_t node)
{
size_t index = node->h.hashcode % list->table_size;
size_t bucket = node->h.hashcode % list->table_size;
gl_hash_entry_t *p;
for (p = &list->table[index]; ; p = &(*p)->hash_next)
for (p = &list->table[bucket]; ; p = &(*p)->hash_next)
{
if (*p == &node->h)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment