OSDN Git Service

* configure.in: Fix typo.
[pf3gnuchains/gcc-fork.git] / gcc / hashtable.c
index f77eb7f..ae7e589 100644 (file)
@@ -21,6 +21,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 #include "config.h"
 #include "system.h"
+#include "coretypes.h"
+#include "tm.h"
 #include "hashtable.h"
 
 /* The code below is a specialization of Vladimir Makarov's expandable
@@ -45,7 +47,7 @@ static void ht_expand PARAMS ((hash_table *));
 #define OBSTACK_CHUNK_FREE free
 #endif
 
-/* Initialise an obstack.  */
+/* Initialize an obstack.  */
 void
 gcc_obstack_init (obstack)
      struct obstack *obstack;
@@ -64,7 +66,7 @@ calc_hash (str, len)
 {
   unsigned int n = len;
   unsigned int r = 0;
-#define HASHSTEP(r, c) ((r) * 67 + (c - 113));
+#define HASHSTEP(r, c) ((r) * 67 + ((c) - 113));
 
   while (n--)
     r = HASHSTEP (r, *str++);
@@ -94,6 +96,17 @@ ht_create (order)
   return table;
 }
 
+/* Frees all memory associated with a hash table.  */
+
+void
+ht_destroy (table)
+     hash_table *table;
+{
+  obstack_free (&table->stack, NULL);
+  free (table->entries);
+  free (table);
+}
+
 /* Returns the hash entry for the a STR of length LEN.  If that string
    already exists in the table, returns the existing entry, and, if
    INSERT is CPP_ALLOCED, frees the last obstack object.  If the
@@ -151,7 +164,7 @@ ht_lookup (table, str, len, insert)
 
   HT_LEN (node) = len;
   if (insert == HT_ALLOC)
-    HT_STR (node) = obstack_copy (&table->stack, str, len + 1);
+    HT_STR (node) = obstack_copy0 (&table->stack, str, len);
   else
     HT_STR (node) = str;