implemented Confirm node
[libfirm] / ir / adt / set.c
index e94f8ee..f43a0a3 100644 (file)
@@ -1,5 +1,14 @@
-/* Set --- collection of entries that are unique wrt to a key.
-   Copyright (C) 1995, 1996 Markus Armbruster */
+/*
+ * Project:     libFIRM
+ * File name:   ir/adt/set.c
+ * Purpose:     Set --- collection of entries that are unique wrt to a key.
+ * Author:      Markus Armbruster
+ * Modified by:
+ * Created:     1999 by getting from fiasco
+ * CVS-ID:      $Id$
+ * Copyright:   (c) 1995, 1996 Markus Armbruster
+ * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ */
 
 /*  This code is derived from:
 
@@ -14,9 +23,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 ;->
  */
 #include <stdio.h>
 #include <string.h>
 #include "misc.h"
+#include "xmalloc.h"
 #ifdef PSET
 # include "pset.h"
 #else
 # include "set.h"
 #endif
 
+
 #define TOBSTACK_ID MANGLEP(tag)
 #include "obst.h"
 
@@ -140,7 +151,7 @@ stat_chain_len (SET *table, int chain_len)
 const char *MANGLEP(tag);
 
 
-void
+static void
 MANGLEP(describe) (SET *table)
 {
   int i, j, collide;
@@ -403,7 +414,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 +431,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;
 }