dict: fix the int problem

This commit is contained in:
zhaozhao.zz 2017-11-30 11:29:05 +08:00 committed by antirez
parent e4903ce586
commit d1176b582c

View File

@ -66,7 +66,7 @@ static unsigned int dict_force_resize_ratio = 5;
static int _dictExpandIfNeeded(dict *ht); static int _dictExpandIfNeeded(dict *ht);
static unsigned long _dictNextPower(unsigned long size); static unsigned long _dictNextPower(unsigned long size);
static int _dictKeyIndex(dict *ht, const void *key, unsigned int hash, dictEntry **existing); static long _dictKeyIndex(dict *ht, const void *key, uint64_t hash, dictEntry **existing);
static int _dictInit(dict *ht, dictType *type, void *privDataPtr); static int _dictInit(dict *ht, dictType *type, void *privDataPtr);
/* -------------------------- hash functions -------------------------------- */ /* -------------------------- hash functions -------------------------------- */
@ -202,7 +202,7 @@ int dictRehash(dict *d, int n) {
de = d->ht[0].table[d->rehashidx]; de = d->ht[0].table[d->rehashidx];
/* Move all the keys in this bucket from the old to the new hash HT */ /* Move all the keys in this bucket from the old to the new hash HT */
while(de) { while(de) {
unsigned int h; uint64_t h;
nextde = de->next; nextde = de->next;
/* Get the index in the new hash table */ /* Get the index in the new hash table */
@ -291,7 +291,7 @@ int dictAdd(dict *d, void *key, void *val)
*/ */
dictEntry *dictAddRaw(dict *d, void *key, dictEntry **existing) dictEntry *dictAddRaw(dict *d, void *key, dictEntry **existing)
{ {
int index; long index;
dictEntry *entry; dictEntry *entry;
dictht *ht; dictht *ht;
@ -362,7 +362,7 @@ dictEntry *dictAddOrFind(dict *d, void *key) {
* dictDelete() and dictUnlink(), please check the top comment * dictDelete() and dictUnlink(), please check the top comment
* of those functions. */ * of those functions. */
static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) { static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) {
unsigned int h, idx; uint64_t h, idx;
dictEntry *he, *prevHe; dictEntry *he, *prevHe;
int table; int table;
@ -476,7 +476,7 @@ void dictRelease(dict *d)
dictEntry *dictFind(dict *d, const void *key) dictEntry *dictFind(dict *d, const void *key)
{ {
dictEntry *he; dictEntry *he;
unsigned int h, idx, table; uint64_t h, idx, table;
if (d->ht[0].used + d->ht[1].used == 0) return NULL; /* dict is empty */ if (d->ht[0].used + d->ht[1].used == 0) return NULL; /* dict is empty */
if (dictIsRehashing(d)) _dictRehashStep(d); if (dictIsRehashing(d)) _dictRehashStep(d);
@ -610,7 +610,7 @@ void dictReleaseIterator(dictIterator *iter)
dictEntry *dictGetRandomKey(dict *d) dictEntry *dictGetRandomKey(dict *d)
{ {
dictEntry *he, *orighe; dictEntry *he, *orighe;
unsigned int h; unsigned long h;
int listlen, listele; int listlen, listele;
if (dictSize(d) == 0) return NULL; if (dictSize(d) == 0) return NULL;
@ -955,9 +955,9 @@ static unsigned long _dictNextPower(unsigned long size)
* *
* Note that if we are in the process of rehashing the hash table, the * Note that if we are in the process of rehashing the hash table, the
* index is always returned in the context of the second (new) hash table. */ * index is always returned in the context of the second (new) hash table. */
static int _dictKeyIndex(dict *d, const void *key, unsigned int hash, dictEntry **existing) static long _dictKeyIndex(dict *d, const void *key, uint64_t hash, dictEntry **existing)
{ {
unsigned int idx, table; unsigned long idx, table;
dictEntry *he; dictEntry *he;
if (existing) *existing = NULL; if (existing) *existing = NULL;
@ -1006,7 +1006,7 @@ unsigned int dictGetHash(dict *d, const void *key) {
* return value is the reference to the dictEntry if found, or NULL if not found. */ * return value is the reference to the dictEntry if found, or NULL if not found. */
dictEntry **dictFindEntryRefByPtrAndHash(dict *d, const void *oldptr, unsigned int hash) { dictEntry **dictFindEntryRefByPtrAndHash(dict *d, const void *oldptr, unsigned int hash) {
dictEntry *he, **heref; dictEntry *he, **heref;
unsigned int idx, table; unsigned long idx, table;
if (d->ht[0].used + d->ht[1].used == 0) return NULL; /* dict is empty */ if (d->ht[0].used + d->ht[1].used == 0) return NULL; /* dict is empty */
for (table = 0; table <= 1; table++) { for (table = 0; table <= 1; table++) {