hasht.c
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:1k
- /*-------------------------------------------------------------------------
- *
- * 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: /usr/local/cvsroot/pgsql/src/backend/lib/hasht.c,v 1.8 1999/02/13 23:15:35 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
- #include <postgres.h>
- #include <utils/memutils.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;
- 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);
- }
- }