summaryrefslogtreecommitdiff
path: root/bfd/hash.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2006-11-20 01:38:38 +0000
committerAlan Modra <amodra@bigpond.net.au>2006-11-20 01:38:38 +0000
commit90cdf78ff463cdb7aaa927ba83b7d555a0e1dbe4 (patch)
treeadfb9e7beedddf1d38f649a367591c7508bc7a63 /bfd/hash.c
parent047594149d533062514bc8f8c6ab6304a35185a2 (diff)
downloadbinutils-redhat-90cdf78ff463cdb7aaa927ba83b7d555a0e1dbe4.tar.gz
PR 3532
* bfd-in.h (struct bfd_hash_table): Reorganize. Add "frozen". * hash.c (bfd_hash_table_init_n): Init frozen. (bfd_hash_lookup): Don't grow if frozen. (bfd_hash_traverse): Freeze hash table during traversal. * bfd-in2.h: Regenerate.
Diffstat (limited to 'bfd/hash.c')
-rw-r--r--bfd/hash.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/bfd/hash.c b/bfd/hash.c
index 3cc4f79644..1157980a8f 100644
--- a/bfd/hash.c
+++ b/bfd/hash.c
@@ -383,6 +383,7 @@ bfd_hash_table_init_n (struct bfd_hash_table *table,
table->size = size;
table->entsize = entsize;
table->count = 0;
+ table->frozen = 0;
table->newfunc = newfunc;
return TRUE;
}
@@ -471,7 +472,7 @@ bfd_hash_lookup (struct bfd_hash_table *table,
table->table[index] = hashp;
table->count++;
- if (table->count > table->size * 3 / 4)
+ if (!table->frozen && table->count > table->size * 3 / 4)
{
unsigned long newsize = higher_prime_number (table->size);
struct bfd_hash_entry **newtable;
@@ -482,8 +483,7 @@ bfd_hash_lookup (struct bfd_hash_table *table,
that much memory, don't try to grow the table. */
if (newsize == 0 || alloc / sizeof (struct bfd_hash_entry *) != newsize)
{
- /* Lie. Stops us trying to grow again for a while. */
- table->count = 0;
+ table->frozen = 1;
return hashp;
}
@@ -573,14 +573,17 @@ bfd_hash_traverse (struct bfd_hash_table *table,
{
unsigned int i;
+ table->frozen = 1;
for (i = 0; i < table->size; i++)
{
struct bfd_hash_entry *p;
for (p = table->table[i]; p != NULL; p = p->next)
if (! (*func) (p, info))
- return;
+ goto out;
}
+ out:
+ table->frozen = 0;
}
void