home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / C / hasht.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  945 b   |  42 lines

  1. /*
  2.  * hasht.c --
  3.  *    hash table related functions that are not directly supported
  4.  *    by the hashing packages under utils/hash.
  5.  *
  6.  */
  7.  
  8. #include "tmp/c.h"
  9. #include "tmp/align.h"
  10.  
  11. RcsId("$Header: /private/postgres/src/lib/C/RCS/hasht.c,v 1.8 1992/08/18 18:27:16 mer Exp $");
  12.  
  13. #include "utils/log.h"
  14. #include "utils/hsearch.h"
  15.  
  16. /* -----------------------------------
  17.  *    HashTableWalk
  18.  *
  19.  *    call function on every element in hashtable
  20.  *    one extra argument, arg may be supplied
  21.  * -----------------------------------
  22.  */
  23. void
  24. HashTableWalk(hashtable, function, arg)
  25. HTAB *hashtable;
  26. void (*function)();
  27. int arg;
  28. {
  29.     int *hashent;
  30.     int *data;
  31.     int keysize;
  32.  
  33.     keysize = hashtable->hctl->keysize;
  34.     (void)hash_seq((HTAB *)NULL);
  35.     while ((hashent = hash_seq(hashtable)) != (int*)TRUE) {
  36.     if (hashent == NULL)
  37.         elog(FATAL, "error in HashTableWalk.");
  38.     data = (int*)LONGALIGN((char*)hashent + keysize);
  39.     (*function)(data, arg);
  40.     }
  41. }
  42.