OSDN Git Service

Correcting ChangeLog errors
[pf3gnuchains/gcc-fork.git] / gcc / pointer-set.c
index 3f79cc2..5daf88b 100644 (file)
@@ -1,5 +1,5 @@
 /* Set operations on pointers
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -15,8 +15,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #include "config.h"
 #include "system.h"
@@ -84,12 +84,36 @@ pointer_set_create (void)
 }
 
 /* Reclaims all memory associated with PSET.  */
-void pointer_set_destroy (struct pointer_set_t *pset)
+void
+pointer_set_destroy (struct pointer_set_t *pset)
 {
   XDELETEVEC (pset->slots);
   XDELETE (pset);
 }
 
+/* Returns nonzero if PSET contains P.  P must be nonnull.
+
+   Collisions are resolved by linear probing.  */
+int
+pointer_set_contains (struct pointer_set_t *pset, void *p)
+{
+  size_t n = hash1 (p, pset->n_slots, pset->log_slots);
+
+  while (true)
+    {
+      if (pset->slots[n] == p)
+       return 1;
+      else if (pset->slots[n] == 0)
+       return 0;
+      else
+       {
+         ++n;
+         if (n == pset->n_slots)
+           n = 0;
+       }
+    }
+}
+
 /* Subroutine of pointer_set_insert.  Inserts P into an empty
    element of SLOTS, an array of length N_SLOTS.  Returns nonzero
    if P was already present in N_SLOTS.  */