~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/backend/utils/hash/hashfn.c

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * hashfn.c
 
4
 *              Hash functions for use in dynahash.c hashtables
 
5
 *
 
6
 *
 
7
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 
8
 * Portions Copyright (c) 1994, Regents of the University of California
 
9
 *
 
10
 *
 
11
 * IDENTIFICATION
 
12
 *        $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.22 2004-12-31 22:01:37 pgsql Exp $
 
13
 *
 
14
 *-------------------------------------------------------------------------
 
15
 */
 
16
#include "postgres.h"
 
17
 
 
18
#include "access/hash.h"
 
19
#include "utils/hsearch.h"
 
20
 
 
21
 
 
22
/*
 
23
 * string_hash: hash function for keys that are null-terminated strings.
 
24
 *
 
25
 * NOTE: this is the default hash function if none is specified.
 
26
 */
 
27
uint32
 
28
string_hash(const void *key, Size keysize)
 
29
{
 
30
        return DatumGetUInt32(hash_any((const unsigned char *) key,
 
31
                                                                   (int) strlen((const char *) key)));
 
32
}
 
33
 
 
34
/*
 
35
 * tag_hash: hash function for fixed-size tag values
 
36
 */
 
37
uint32
 
38
tag_hash(const void *key, Size keysize)
 
39
{
 
40
        return DatumGetUInt32(hash_any((const unsigned char *) key,
 
41
                                                                   (int) keysize));
 
42
}