Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
b37099a1
Commit
b37099a1
authored
Nov 30, 2017
by
zhaozhao.zz
Committed by
antirez
Dec 05, 2017
Browse files
dict: fix the int problem
parent
8fe586d3
Changes
1
Show whitespace changes
Inline
Side-by-side
src/dict.c
View file @
b37099a1
...
@@ -66,7 +66,7 @@ static unsigned int dict_force_resize_ratio = 5;
...
@@ -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
,
u
nsigned
in
t
hash
,
dictEntry
**
existing
);
static
long
_dictKeyIndex
(
dict
*
ht
,
const
void
*
key
,
u
int64_
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) {
...
@@ -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
)
{
u
nsigned
in
t
h
;
u
int64_
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)
...
@@ -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) {
...
@@ -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
)
{
u
nsigned
in
t
h
,
idx
;
u
int64_
t
h
,
idx
;
dictEntry
*
he
,
*
prevHe
;
dictEntry
*
he
,
*
prevHe
;
int
table
;
int
table
;
...
@@ -476,7 +476,7 @@ void dictRelease(dict *d)
...
@@ -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
;
u
nsigned
in
t
h
,
idx
,
table
;
u
int64_
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)
...
@@ -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)
...
@@ -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
,
u
nsigned
in
t
hash
,
dictEntry
**
existing
)
static
long
_dictKeyIndex
(
dict
*
d
,
const
void
*
key
,
u
int64_
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) {
...
@@ -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
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment