gdbserver: include aarch32/aarch64 header file in corresponding source file
[deliverable/binutils-gdb.git] / gas / hash.c
index 6fc8543a90dde5953ac8cb6f66f8ae9e5af32fe0..c484588606611ebf27d26e17ae0605f8d4cc190e 100644 (file)
@@ -1,7 +1,5 @@
 /* hash.c -- gas hash table code
-   Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
-   2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 1987-2020 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -78,42 +76,18 @@ static unsigned long gas_hash_table_size = 65537;
 void
 set_gas_hash_table_size (unsigned long size)
 {
-  gas_hash_table_size = size;
-}
-
-/* FIXME: This function should be amalgmated with bfd/hash.c:bfd_hash_set_default_size().  */
-static unsigned long
-get_gas_hash_table_size (void)
-{
-  /* Extend this prime list if you want more granularity of hash table size.  */
-  static const unsigned long hash_size_primes[] =
-    {
-      1021, 4051, 8599, 16699, 65537
-    };
-  unsigned int hindex;
-
-  /* Work out the best prime number near the hash_size.
-     FIXME: This could be a more sophisticated algorithm,
-     but is it really worth implementing it ?   */
-  for (hindex = 0; hindex < ARRAY_SIZE (hash_size_primes) - 1; ++ hindex)
-    if (gas_hash_table_size <= hash_size_primes[hindex])
-      break;
-
-  return hash_size_primes[hindex];
+  gas_hash_table_size = bfd_hash_set_default_size (size);
 }
 
 /* Create a hash table.  This return a control block.  */
 
 struct hash_control *
-hash_new (void)
+hash_new_sized (unsigned long size)
 {
-  unsigned long size;
   unsigned long alloc;
   struct hash_control *ret;
 
-  size = get_gas_hash_table_size ();
-
-  ret = (struct hash_control *) xmalloc (sizeof *ret);
+  ret = XNEW (struct hash_control);
   obstack_begin (&ret->memory, chunksize);
   alloc = size * sizeof (struct hash_entry *);
   ret->table = (struct hash_entry **) obstack_alloc (&ret->memory, alloc);
@@ -132,6 +106,12 @@ hash_new (void)
   return ret;
 }
 
+struct hash_control *
+hash_new (void)
+{
+  return hash_new_sized (gas_hash_table_size);
+}
+
 /* Delete a hash table, freeing all allocated memory.  */
 
 void
This page took 0.024333 seconds and 4 git commands to generate.