7
7
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $PostgreSQL: pgsql/src/include/utils/hsearch.h,v 1.37 2005/06/08 23:02:05 tgl Exp $
10
+ * $PostgreSQL: pgsql/src/include/utils/hsearch.h,v 1.38 2005/06/18 20:51:30 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
16
16
17
17
18
18
/*
19
- * Hash and comparison functions must have these signatures. Comparison
20
- * functions return zero for match, nonzero for no match. (The comparison
21
- * function definition is designed to allow memcmp() and strncmp() to be
22
- * used directly as key comparison functions.)
19
+ * Hash functions must have this signature.
23
20
*/
24
21
typedef uint32 (* HashValueFunc ) (const void * key , Size keysize );
22
+
23
+ /*
24
+ * Key comparison functions must have this signature. Comparison functions
25
+ * return zero for match, nonzero for no match. (The comparison function
26
+ * definition is designed to allow memcmp() and strncmp() to be used directly
27
+ * as key comparison functions.)
28
+ */
25
29
typedef int (* HashCompareFunc ) (const void * key1 , const void * key2 ,
26
- Size keysize );
30
+ Size keysize );
31
+
32
+ /*
33
+ * Key copying functions must have this signature. The return value is not
34
+ * used. (The definition is set up to allow memcpy() and strncpy() to be
35
+ * used directly.)
36
+ */
37
+ typedef void * (* HashCopyFunc ) (void * dest , const void * src , Size keysize );
27
38
28
39
/*
29
40
* Space allocation function for a hashtable --- designed to match malloc().
@@ -103,6 +114,7 @@ typedef struct HTAB
103
114
HASHSEGMENT * dir ; /* directory of segment starts */
104
115
HashValueFunc hash ; /* hash function */
105
116
HashCompareFunc match ; /* key comparison function */
117
+ HashCopyFunc keycopy ; /* key copying function */
106
118
HashAllocFunc alloc ; /* memory allocator */
107
119
MemoryContext hcxt ; /* memory context if default allocator
108
120
* used */
@@ -123,6 +135,7 @@ typedef struct HASHCTL
123
135
Size entrysize ; /* total user element size in bytes */
124
136
HashValueFunc hash ; /* hash function */
125
137
HashCompareFunc match ; /* key comparison function */
138
+ HashCopyFunc keycopy ; /* key copying function */
126
139
HashAllocFunc alloc ; /* memory allocator */
127
140
HASHSEGMENT * dir ; /* directory of segment starts */
128
141
HASHHDR * hctl ; /* location of header in shared mem */
@@ -140,6 +153,7 @@ typedef struct HASHCTL
140
153
#define HASH_ALLOC 0x100 /* Set memory allocator */
141
154
#define HASH_CONTEXT 0x200 /* Set explicit memory context */
142
155
#define HASH_COMPARE 0x400 /* Set user defined comparison function */
156
+ #define HASH_KEYCOPY 0x800 /* Set user defined key-copying function */
143
157
144
158
145
159
/* max_dsize value to indicate expansible directory */
0 commit comments