#include "system.h"
#include <rpmlib.h>
#include "rpmhash.h"
#include "debug.h"
Go to the source code of this file.
Data Structures | |
struct | hashBucket_s |
struct | hashTable_s |
Typedefs | |
typedef const void * | voidptr |
typedef hashBucket_s * | hashBucket |
Functions | |
static hashBucket | findEntry (hashTable ht, const void *key) |
Find entry in hash table. | |
int | hashEqualityString (const void *key1, const void *key2) |
Compare two hash table entries for equality. | |
unsigned int | hashFunctionString (const void *string) |
Return hash value of a string. | |
hashTable | htCreate (int numBuckets, int keySize, int freeData, hashFunctionType fn, hashEqualityType eq) |
Create hash table. | |
void | htAddEntry (hashTable ht, const void *key, const void *data) |
Add item to hash table. | |
hashTable | htFree (hashTable ht) |
Destroy hash table. | |
int | htHasEntry (hashTable ht, const void *key) |
Check for key in hash table. | |
int | htGetEntry (hashTable ht, const void *key, const void ***data, int *dataCount, const void **tableKey) |
Retrieve item from hash table. |
Definition in file rpmhash.c.
typedef struct hashBucket_s* hashBucket |
static hashBucket findEntry | ( | hashTable | ht, | |
const void * | key | |||
) | [static] |
Find entry in hash table.
ht | pointer to hash table | |
key | pointer to key value |
Definition at line 42 of file rpmhash.c.
References hashTable_s::buckets, hashTable_s::eq, hashTable_s::fn, hashBucket_s::key, hashBucket_s::next, and hashTable_s::numBuckets.
int hashEqualityString | ( | const void * | key1, | |
const void * | key2 | |||
) |
Compare two hash table entries for equality.
key1 | entry 1 | |
key2 | entry 2 |
Definition at line 61 of file rpmhash.c.
Referenced by fpCacheCreate().
unsigned int hashFunctionString | ( | const void * | string | ) |
Return hash value of a string.
string | string on which to calculate hash value |
Definition at line 68 of file rpmhash.c.
Referenced by fpCacheCreate().
void htAddEntry | ( | hashTable | ht, | |
const void * | key, | |||
const void * | data | |||
) |
Add item to hash table.
ht | pointer to hash table | |
key | pointer to key | |
data | pointer to data value |
Definition at line 106 of file rpmhash.c.
References hashTable_s::buckets, hashBucket_s::data, hashBucket_s::dataCount, hashTable_s::eq, hashTable_s::fn, hashBucket_s::key, hashTable_s::keySize, hashBucket_s::next, hashTable_s::numBuckets, xmalloc(), and xrealloc().
Referenced by doLookup(), and rpmtsRun().
hashTable htCreate | ( | int | numBuckets, | |
int | keySize, | |||
int | freeData, | |||
hashFunctionType | fn, | |||
hashEqualityType | eq | |||
) |
Create hash table.
If keySize > 0, the key is duplicated within the table (which costs memory, but may be useful anyway.
numBuckets | number of hash buckets | |
keySize | size of key (0 if unknown) | |
freeData | Should data be freed when table is destroyed? | |
fn | function to generate hash value for key | |
eq | function to compare hash keys for equality |
Definition at line 87 of file rpmhash.c.
References xcalloc(), and xmalloc().
Referenced by fpCacheCreate(), and rpmtsRun().
Destroy hash table.
ht | pointer to hash table |
Definition at line 139 of file rpmhash.c.
References _free(), hashTable_s::buckets, hashBucket_s::data, hashTable_s::freeData, hashBucket_s::key, hashTable_s::keySize, hashBucket_s::next, and hashTable_s::numBuckets.
Referenced by fpCacheFree(), and rpmtsRun().
int htGetEntry | ( | hashTable | ht, | |
const void * | key, | |||
const void *** | data, | |||
int * | dataCount, | |||
const void ** | tableKey | |||
) |
Retrieve item from hash table.
ht | pointer to hash table | |
key | pointer to key value |
data | address to store data value from bucket | |
dataCount | address to store data value size from bucket | |
tableKey | address to store key value from bucket (may be NULL) |
Definition at line 182 of file rpmhash.c.
References hashBucket_s::data, hashBucket_s::dataCount, findEntry(), and hashBucket_s::key.
Referenced by cacheContainsDirectory(), and handleOverlappedFiles().
int htHasEntry | ( | hashTable | ht, | |
const void * | key | |||
) |
Check for key in hash table.
ht | pointer to hash table | |
key | pointer to key value |
Definition at line 175 of file rpmhash.c.
References findEntry().