rpm  5.4.10
rpmhash.h
Go to the documentation of this file.
1 #ifndef H_RPMHASH
2 #define H_RPMHASH
3 
9 #include <rpmiotypes.h>
10 
13 typedef /*@abstract@*/ /*@refcounted@*/ struct hashTable_s * hashTable;
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
25 typedef int (*hashEqualityType) (const void * key1, const void * key2)
26  /*@*/;
27 
34 int hashEqualityString(const void * key1, const void * key2)
35  /*@*/;
36 
44 typedef rpmuint32_t (*hashFunctionType) (rpmuint32_t h, const void * data,
45  size_t size)
46  /*@*/;
47 
55 rpmuint32_t hashFunctionString(rpmuint32_t h, const void * data, size_t size)
56  /*@*/;
57 
64 void htAddEntry(hashTable ht, /*@owned@*/ const void * key,
65  /*@owned@*/ const void * data)
66  /*@modifies ht */;
67 
77 int htGetEntry(hashTable ht, const void * key,
78  /*@null@*/ /*@out@*/ const void * data,
79  /*@null@*/ /*@out@*/ int * dataCount,
80  /*@null@*/ /*@out@*/ const void * tableKey)
81  /*@modifies *data, *dataCount, *tableKey @*/;
82 
88 const void ** htGetKeys(hashTable ht)
89  /*@*/;
90 
97 /*@unused@*/
98 int htHasEntry(hashTable ht, const void * key)
99  /*@*/;
100 
106 /*@unused@*/ /*@null@*/
107 hashTable htUnlink (/*@killref@*/ /*@null@*/ hashTable ht)
108  /*@modifies ht @*/;
109 #define htUnlink(_ht) \
110  ((hashTable)rpmioUnlinkPoolItem((rpmioItem)(_ht), __FUNCTION__, __FILE__, __LINE__))
111 
117 /*@unused@*/ /*@newref@*/ /*@null@*/
118 hashTable htLink (/*@null@*/ hashTable ht)
119  /*@modifies ht @*/;
120 #define htLink(_ht) \
121  ((hashTable)rpmioLinkPoolItem((rpmioItem)(_ht), __FUNCTION__, __FILE__, __LINE__))
122 
128 /*@null@*/
129 hashTable htFree( /*@only@*/ hashTable ht)
130  /*@modifies ht @*/;
131 #define htFree(_ht) \
132  ((hashTable)rpmioFreePoolItem((rpmioItem)(_ht), __FUNCTION__, __FILE__, __LINE__))
133 
145 /*@newref@*/ /*@null@*/
146 hashTable htCreate(int numBuckets, size_t keySize, int freeData,
147  /*@null@*/ hashFunctionType fn, /*@null@*/ hashEqualityType eq)
148  /*@globals fileSystem @*/
149  /*@modifies fileSystem @*/;
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 
155 #endif
int hashEqualityString(const void *key1, const void *key2)
Compare two hash table entries for equality.
Definition: rpmhash.c:76
int freeData
Definition: rpmhash.c:34
#define htUnlink(_ht)
Definition: rpmhash.h:109
int(* hashEqualityType)(const void *key1, const void *key2)
Compare two hash table entries for equality.
Definition: rpmhash.h:25
#define htLink(_ht)
Definition: rpmhash.h:120
void htAddEntry(hashTable ht, const void *key, const void *data)
Add item to hash table.
Definition: rpmhash.c:150
int htHasEntry(hashTable ht, const void *key)
Check for key in hash table.
Definition: rpmhash.c:181
unsigned int rpmuint32_t
Definition: rpmiotypes.h:25
hashFunctionType fn
Definition: rpmhash.c:37
rpmuint32_t(* hashFunctionType)(rpmuint32_t h, const void *data, size_t size)
Return hash value.
Definition: rpmhash.h:44
rpmuint32_t hashFunctionString(rpmuint32_t h, const void *data, size_t size)
Return hash value of a string.
Definition: rpmhash.c:83
int numBuckets
Definition: rpmhash.c:32
size_t keySize
Definition: rpmhash.c:33
hashTable htCreate(int numBuckets, size_t keySize, int freeData, hashFunctionType fn, hashEqualityType eq)
Create hash table.
Definition: rpmhash.c:277
int htGetEntry(hashTable ht, const void *key, const void *data, int *dataCount, const void *tableKey)
Retrieve item from hash table.
Definition: rpmhash.c:188
const void ** htGetKeys(hashTable ht)
Retrieve keys from hash table.
Definition: rpmhash.c:206
#define htFree(_ht)
Definition: rpmhash.h:131
struct hashTable_s * hashTable
Definition: rpmhash.h:13
hashEqualityType eq
Definition: rpmhash.c:39