aboutsummaryrefslogtreecommitdiff
path: root/src/backend/lib/hasht.c
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1996-07-09 06:22:35 +0000
committerMarc G. Fournier <scrappy@hub.org>1996-07-09 06:22:35 +0000
commitd31084e9d1118b25fd16580d9d8c2924b5740dff (patch)
tree3179e66307d54df9c7b966543550e601eb55e668 /src/backend/lib/hasht.c
downloadpostgresql-PG95-1_01.tar.gz
postgresql-PG95-1_01.zip
Postgres95 1.01 Distribution - Virgin SourcesPG95-1_01
Diffstat (limited to 'src/backend/lib/hasht.c')
-rw-r--r--src/backend/lib/hasht.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/backend/lib/hasht.c b/src/backend/lib/hasht.c
new file mode 100644
index 00000000000..5487bed44bc
--- /dev/null
+++ b/src/backend/lib/hasht.c
@@ -0,0 +1,47 @@
+/*-------------------------------------------------------------------------
+ *
+ * hasht.c--
+ * hash table related functions that are not directly supported
+ * by the hashing packages under utils/hash.
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/backend/lib/Attic/hasht.c,v 1.1.1.1 1996/07/09 06:21:29 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#include "c.h"
+#include "utils/memutils.h"
+#include "utils/elog.h"
+#include "utils/hsearch.h"
+#include "lib/hasht.h"
+
+/* -----------------------------------
+ * HashTableWalk
+ *
+ * call function on every element in hashtable
+ * one extra argument, arg may be supplied
+ * -----------------------------------
+ */
+void
+HashTableWalk(HTAB *hashtable, HashtFunc function, int arg)
+{
+ long *hashent;
+ long *data;
+ int keysize;
+
+ keysize = hashtable->hctl->keysize;
+ (void)hash_seq((HTAB *)NULL);
+ while ((hashent = hash_seq(hashtable)) != (long *) TRUE) {
+ if (hashent == NULL)
+ elog(FATAL, "error in HashTableWalk.");
+ /*
+ * XXX the corresponding hash table insertion does NOT
+ * LONGALIGN -- make sure the keysize is ok
+ */
+ data = (long *) LONGALIGN((char*) hashent + keysize);
+ (*function)(data, arg);
+ }
+}