From 068d3c9737b368f921808e753f6f000a12ca5ae8 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 27 Mar 2015 10:14:52 +0100 Subject: [PATCH] dict.c: convert types to unsigned long where appropriate. No semantical changes since to make dict.c truly able to scale over the 32 bit table size limit, the hash function shoulds and other internals related to hash function output should be 64 bit ready. --- src/dict.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dict.c b/src/dict.c index c6dbceaf..f728d381 100644 --- a/src/dict.c +++ b/src/dict.c @@ -687,10 +687,10 @@ dictEntry *dictGetRandomKey(dict *d) * statistics. However the function is much faster than dictGetRandomKey() * at producing N elements. */ unsigned int dictGetSomeKeys(dict *d, dictEntry **des, unsigned int count) { - unsigned int j; /* internal hash table id, 0 or 1. */ - unsigned int tables; /* 1 or 2 tables? */ - unsigned int stored = 0, maxsizemask; - unsigned int maxsteps; + unsigned long j; /* internal hash table id, 0 or 1. */ + unsigned long tables; /* 1 or 2 tables? */ + unsigned long stored = 0, maxsizemask; + unsigned long maxsteps; if (dictSize(d) < count) count = dictSize(d); maxsteps = count*10; @@ -709,14 +709,14 @@ unsigned int dictGetSomeKeys(dict *d, dictEntry **des, unsigned int count) { maxsizemask = d->ht[1].sizemask; /* Pick a random point inside the larger table. */ - unsigned int i = random() & maxsizemask; - unsigned int emptylen = 0; /* Continuous empty entries so far. */ + unsigned long i = random() & maxsizemask; + unsigned long emptylen = 0; /* Continuous empty entries so far. */ while(stored < count && maxsteps--) { for (j = 0; j < tables; j++) { /* Invariant of the dict.c rehashing: up to the indexes already * visited in ht[0] during the rehashing, there are no populated * buckets, so we can skip ht[0] for indexes between 0 and idx-1. */ - if (tables == 2 && j == 0 && i < (unsigned int) d->rehashidx) { + if (tables == 2 && j == 0 && i < (unsigned long) d->rehashidx) { /* Moreover, if we are currently out of range in the second * table, there will be no elements in both tables up to * the current rehashing index, so we jump if possible.