/* hash.c -- hash table routines for BFD
Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007 Free Software Foundation, Inc.
+ 2006, 2007, 2009 Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
This file is part of BFD, the Binary File Descriptor library.
bfd_set_error (bfd_error_no_memory);
return FALSE;
}
- table->table = objalloc_alloc ((struct objalloc *) table->memory, alloc);
+ table->table = (struct bfd_hash_entry **)
+ objalloc_alloc ((struct objalloc *) table->memory, alloc);
if (table->table == NULL)
{
bfd_set_error (bfd_error_no_memory);
void
bfd_hash_table_free (struct bfd_hash_table *table)
{
- objalloc_free (table->memory);
+ objalloc_free ((struct objalloc *) table->memory);
table->memory = NULL;
}
unsigned int c;
struct bfd_hash_entry *hashp;
unsigned int len;
- unsigned int index;
+ unsigned int _index;
hash = 0;
len = 0;
hash += len + (len << 17);
hash ^= hash >> 2;
- index = hash % table->size;
- for (hashp = table->table[index];
+ _index = hash % table->size;
+ for (hashp = table->table[_index];
hashp != NULL;
hashp = hashp->next)
{
if (copy)
{
- char *new;
+ char *new_string;
- new = objalloc_alloc ((struct objalloc *) table->memory, len + 1);
- if (!new)
+ new_string = (char *) objalloc_alloc ((struct objalloc *) table->memory,
+ len + 1);
+ if (!new_string)
{
bfd_set_error (bfd_error_no_memory);
return NULL;
}
- memcpy (new, string, len + 1);
- string = new;
+ memcpy (new_string, string, len + 1);
+ string = new_string;
}
return bfd_hash_insert (table, string, hash);
unsigned long hash)
{
struct bfd_hash_entry *hashp;
- unsigned int index;
+ unsigned int _index;
hashp = (*table->newfunc) (NULL, table, string);
if (hashp == NULL)
return NULL;
hashp->string = string;
hashp->hash = hash;
- index = hash % table->size;
- hashp->next = table->table[index];
- table->table[index] = hashp;
+ _index = hash % table->size;
+ hashp->next = table->table[_index];
+ table->table[_index] = hashp;
table->count++;
if (!table->frozen && table->count > table->size * 3 / 4)
chain_end = chain_end->next;
table->table[hi] = chain_end->next;
- index = chain->hash % newsize;
- chain_end->next = newtable[index];
- newtable[index] = chain;
+ _index = chain->hash % newsize;
+ chain_end->next = newtable[_index];
+ newtable[_index] = chain;
}
table->table = newtable;
table->size = newsize;
struct bfd_hash_entry *old,
struct bfd_hash_entry *nw)
{
- unsigned int index;
+ unsigned int _index;
struct bfd_hash_entry **pph;
- index = old->hash % table->size;
- for (pph = &table->table[index];
+ _index = old->hash % table->size;
+ for (pph = &table->table[_index];
(*pph) != NULL;
pph = &(*pph)->next)
{
const char *string ATTRIBUTE_UNUSED)
{
if (entry == NULL)
- entry = bfd_hash_allocate (table, sizeof (* entry));
+ entry = (struct bfd_hash_entry *) bfd_hash_allocate (table,
+ sizeof (* entry));
return entry;
}
{
251, 509, 1021, 2039, 4051, 8599, 16699, 32749
};
- size_t index;
+ size_t _index;
/* Work out best prime number near the hash_size. */
- for (index = 0; index < ARRAY_SIZE (hash_size_primes) - 1; ++index)
- if (hash_size <= hash_size_primes[index])
+ for (_index = 0; _index < ARRAY_SIZE (hash_size_primes) - 1; ++_index)
+ if (hash_size <= hash_size_primes[_index])
break;
- bfd_default_hash_table_size = hash_size_primes[index];
+ bfd_default_hash_table_size = hash_size_primes[_index];
}
\f
/* A few different object file formats (a.out, COFF, ELF) use a string
/* Allocate the structure if it has not already been allocated by a
subclass. */
if (ret == NULL)
- ret = bfd_hash_allocate (table, sizeof (* ret));
+ ret = (struct strtab_hash_entry *) bfd_hash_allocate (table,
+ sizeof (* ret));
if (ret == NULL)
return NULL;
struct bfd_strtab_hash *table;
bfd_size_type amt = sizeof (* table);
- table = bfd_malloc (amt);
+ table = (struct bfd_strtab_hash *) bfd_malloc (amt);
if (table == NULL)
return NULL;
}
else
{
- entry = bfd_hash_allocate (&tab->table, sizeof (* entry));
+ entry = (struct strtab_hash_entry *) bfd_hash_allocate (&tab->table,
+ sizeof (* entry));
if (entry == NULL)
return (bfd_size_type) -1;
if (! copy)
{
char *n;
- n = bfd_hash_allocate (&tab->table, strlen (str) + 1);
+ n = (char *) bfd_hash_allocate (&tab->table, strlen (str) + 1);
if (n == NULL)
return (bfd_size_type) -1;
entry->root.string = n;