Typo fixed.
[libfirm] / ir / adt / set.c
index 2e08389..2db9ffa 100644 (file)
@@ -14,9 +14,9 @@
     Submitted-By: Esmond Pitt <ejp@ausmelb.oz.AU>
     Archive-name: dynamic-hash
 
-    ** Dynamic hashing, after CACM April 1988 pp 446-457, by Per-Ake Larson.
-    ** Coded into C, with minor code improvements, and with hsearch(3) interface,
-    ** by ejp@ausmelb.oz, Jul 26, 1988: 13:16;
+    * Dynamic hashing, after CACM April 1988 pp 446-457, by Per-Ake Larson.
+    * Coded into C, with minor code improvements, and with hsearch(3) interface,
+    * by ejp@ausmelb.oz, Jul 26, 1988: 13:16;
 
     TODO: Fix Esmond's ugly MixedCapsIdentifiers ;->
  */
@@ -105,7 +105,7 @@ struct SET {
 
 #ifdef STATS
 
-static void
+void
 MANGLEP(stats) (SET *table)
 {
   int nfree = 0;
@@ -208,7 +208,7 @@ SET *
 }
 
 
-static void
+void
 PMANGLE(del) (SET *table)
 {
 #ifdef DEBUG
@@ -233,7 +233,7 @@ iter_step (SET *table)
 }
 
 
-static void *
+void *
 MANGLEP(first) (SET *table)
 {
   assert (!table->iter_tail);
@@ -248,7 +248,7 @@ MANGLEP(first) (SET *table)
 }
 
 
-static void *
+void *
 MANGLEP(next) (SET *table)
 {
   assert (table->iter_tail);
@@ -263,7 +263,7 @@ MANGLEP(next) (SET *table)
   return table->iter_tail->entry.dptr;
 }
 
-static void
+void
 MANGLEP(break) (SET *table)
 {
   assert (table->iter_tail);
@@ -403,7 +403,10 @@ MANGLE(_,_search) (SET *table,
     q->entry.dptr = (void *)key;
 #else
     obstack_blank (&table->obst, offsetof (Element, entry.dptr));
-    obstack_grow (&table->obst, key, size);
+    if (action == _set_hinsert0)
+      obstack_grow0 (&table->obst, key, size);
+    else
+      obstack_grow (&table->obst, key, size);
     q = obstack_finish (&table->obst);
     q->entry.size = size;
 #endif
@@ -417,7 +420,11 @@ MANGLE(_,_search) (SET *table,
   }
 
   if (!q) return NULL;
-  if (action == MANGLE(_,_hinsert)) return &q->entry;
+#ifdef PSET
+  if (action == _pset_hinsert) return &q->entry;
+#else
+  if (action == _set_hinsert || action == _set_hinsert0) return &q->entry;
+#endif
   return q->entry.dptr;
 }