diff options
author | jbj <devnull@localhost> | 1999-10-27 23:18:10 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 1999-10-27 23:18:10 +0000 |
commit | 0d0b405c201b43f2eebc61257f5992931e1cdb0c (patch) | |
tree | 7b19eee73f74dbd86e65255cff8be16b58292035 /lib/hash.c | |
parent | 82c75cb6a261465700ca469793b54ad68bef99a8 (diff) | |
download | rpm-0d0b405c201b43f2eebc61257f5992931e1cdb0c.tar.gz rpm-0d0b405c201b43f2eebc61257f5992931e1cdb0c.tar.bz2 rpm-0d0b405c201b43f2eebc61257f5992931e1cdb0c.zip |
use compressed filenames on install side.
start unifying FD types, CFD_t now gone.
CVS patchset: 3402
CVS date: 1999/10/27 23:18:10
Diffstat (limited to 'lib/hash.c')
-rw-r--r-- | lib/hash.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/hash.c b/lib/hash.c index 8dc7339b1..a8dd8695c 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -24,9 +24,9 @@ static /*@shared@*/ struct hashBucket * findEntry(hashTable ht, const void * key struct hashBucket * b; hash = ht->fn(key) % ht->numBuckets; - b = ht->buckets[hash]; + b = ht->buckets[hash]; - while (b && b->key && !ht->eq(b->key, key)) + while (b && b->key && ht->eq(b->key, key)) b = b->next; return b; @@ -74,15 +74,15 @@ hashTable htCreate(int numBuckets, int keySize, hashFunctionType fn, void htAddEntry(hashTable ht, const void * key, const void * data) { unsigned int hash; - struct hashBucket * b, * ob; + struct hashBucket * b; hash = ht->fn(key) % ht->numBuckets; - b = ob = ht->buckets[hash]; + b = ht->buckets[hash]; - while (b && b->key && !ht->eq(b->key, key)) + while (b && b->key && ht->eq(b->key, key)) b = b->next; - - if (!b) { + + if (b == NULL) { b = xmalloc(sizeof(*b)); if (ht->keySize) { char *k = xmalloc(ht->keySize); @@ -128,16 +128,20 @@ int htHasEntry(hashTable ht, const void * key) if (!(b = findEntry(ht, key))) return 0; else return 1; } -int htGetEntry(hashTable ht, const void * key, const void *** data, +int htGetEntry(hashTable ht, const void * key, const void *** data, int * dataCount, const void ** tableKey) { struct hashBucket * b; - if (!(b = findEntry(ht, key))) return 1; + if ((b = findEntry(ht, key)) == NULL) + return 1; - *data = b->data; - *dataCount = b->dataCount; - if (tableKey) *tableKey = b->key; + if (data) + *data = b->data; + if (dataCount) + *dataCount = b->dataCount; + if (tableKey) + *tableKey = b->key; return 0; } |