summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/libiberty/hashtab.c
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2010-11-01 19:35:33 +0000
committerdim <dim@FreeBSD.org>2010-11-01 19:35:33 +0000
commit3f5c947f4453c6016a2a6a9636367ee3f48fc6fc (patch)
tree461aafc934d462eb9b9221308f8e25238c0ada62 /contrib/binutils/libiberty/hashtab.c
parente6be3e7867eb43d220575baee2ce5662fb03e46c (diff)
parentd0f678fa0ff3f08a4eca29daf4d1ac39797b6326 (diff)
downloadFreeBSD-src-3f5c947f4453c6016a2a6a9636367ee3f48fc6fc.zip
FreeBSD-src-3f5c947f4453c6016a2a6a9636367ee3f48fc6fc.tar.gz
Merge ^/vendor/binutils/dist@214571 into contrib/binutils, which brings
us up to version 2.17.50.20070703, at the last GPLv2 commit. Amongst others, this added upstream support for some FreeBSD-specific things that we previously had to manually hack in, such as the OSABI label support, and so on. There are also quite a number of new files, some for cpu's (e.g. SPU) that we may or may not be interested in, but those can be cleaned up later on, if needed.
Diffstat (limited to 'contrib/binutils/libiberty/hashtab.c')
-rw-r--r--contrib/binutils/libiberty/hashtab.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/contrib/binutils/libiberty/hashtab.c b/contrib/binutils/libiberty/hashtab.c
index a5671a0..bf34a6d 100644
--- a/contrib/binutils/libiberty/hashtab.c
+++ b/contrib/binutils/libiberty/hashtab.c
@@ -421,7 +421,28 @@ htab_empty (htab_t htab)
if (entries[i] != HTAB_EMPTY_ENTRY && entries[i] != HTAB_DELETED_ENTRY)
(*htab->del_f) (entries[i]);
- memset (entries, 0, size * sizeof (PTR));
+ /* Instead of clearing megabyte, downsize the table. */
+ if (size > 1024*1024 / sizeof (PTR))
+ {
+ int nindex = higher_prime_index (1024 / sizeof (PTR));
+ int nsize = prime_tab[nindex].prime;
+
+ if (htab->free_f != NULL)
+ (*htab->free_f) (htab->entries);
+ else if (htab->free_with_arg_f != NULL)
+ (*htab->free_with_arg_f) (htab->alloc_arg, htab->entries);
+ if (htab->alloc_with_arg_f != NULL)
+ htab->entries = (PTR *) (*htab->alloc_with_arg_f) (htab->alloc_arg, nsize,
+ sizeof (PTR *));
+ else
+ htab->entries = (PTR *) (*htab->alloc_f) (nsize, sizeof (PTR *));
+ htab->size = nsize;
+ htab->size_prime_index = nindex;
+ }
+ else
+ memset (entries, 0, size * sizeof (PTR));
+ htab->n_deleted = 0;
+ htab->n_elements = 0;
}
/* Similar to htab_find_slot, but without several unwanted side effects:
OpenPOWER on IntegriCloud