Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
7d99b563
Unverified
Commit
7d99b563
authored
Jan 26, 2021
by
Michael Grunder
Committed by
GitHub
Jan 26, 2021
Browse files
Merge pull request #917 from Nordix/stack-alloc-dict-iter
Stack allocate dict iterators
parents
4bba7210
920128a2
Changes
3
Show whitespace changes
Inline
Side-by-side
async.c
View file @
7d99b563
...
...
@@ -306,7 +306,7 @@ static void __redisRunPushCallback(redisAsyncContext *ac, redisReply *reply) {
static
void
__redisAsyncFree
(
redisAsyncContext
*
ac
)
{
redisContext
*
c
=
&
(
ac
->
c
);
redisCallback
cb
;
dictIterator
*
it
;
dictIterator
it
;
dictEntry
*
de
;
/* Execute pending callbacks with NULL reply. */
...
...
@@ -319,23 +319,17 @@ static void __redisAsyncFree(redisAsyncContext *ac) {
/* Run subscription callbacks with NULL reply */
if
(
ac
->
sub
.
channels
)
{
it
=
dictGetIterator
(
ac
->
sub
.
channels
);
if
(
it
!=
NULL
)
{
while
((
de
=
dictNext
(
it
))
!=
NULL
)
dictInitIterator
(
&
it
,
ac
->
sub
.
channels
);
while
((
de
=
dictNext
(
&
it
))
!=
NULL
)
__redisRunCallback
(
ac
,
dictGetEntryVal
(
de
),
NULL
);
dictReleaseIterator
(
it
);
}
dictRelease
(
ac
->
sub
.
channels
);
}
if
(
ac
->
sub
.
patterns
)
{
it
=
dictGetIterator
(
ac
->
sub
.
patterns
);
if
(
it
!=
NULL
)
{
while
((
de
=
dictNext
(
it
))
!=
NULL
)
dictInitIterator
(
&
it
,
ac
->
sub
.
patterns
);
while
((
de
=
dictNext
(
&
it
))
!=
NULL
)
__redisRunCallback
(
ac
,
dictGetEntryVal
(
de
),
NULL
);
dictReleaseIterator
(
it
);
}
dictRelease
(
ac
->
sub
.
patterns
);
}
...
...
dict.c
View file @
7d99b563
...
...
@@ -267,16 +267,11 @@ static dictEntry *dictFind(dict *ht, const void *key) {
return
NULL
;
}
static
dictIterator
*
dictGetIterator
(
dict
*
ht
)
{
dictIterator
*
iter
=
hi_malloc
(
sizeof
(
*
iter
));
if
(
iter
==
NULL
)
return
NULL
;
static
void
dictInitIterator
(
dictIterator
*
iter
,
dict
*
ht
)
{
iter
->
ht
=
ht
;
iter
->
index
=
-
1
;
iter
->
entry
=
NULL
;
iter
->
nextEntry
=
NULL
;
return
iter
;
}
static
dictEntry
*
dictNext
(
dictIterator
*
iter
)
{
...
...
@@ -299,10 +294,6 @@ static dictEntry *dictNext(dictIterator *iter) {
return
NULL
;
}
static
void
dictReleaseIterator
(
dictIterator
*
iter
)
{
hi_free
(
iter
);
}
/* ------------------------- private functions ------------------------------ */
/* Expand the hash table if needed */
...
...
dict.h
View file @
7d99b563
...
...
@@ -119,8 +119,7 @@ static int dictReplace(dict *ht, void *key, void *val);
static
int
dictDelete
(
dict
*
ht
,
const
void
*
key
);
static
void
dictRelease
(
dict
*
ht
);
static
dictEntry
*
dictFind
(
dict
*
ht
,
const
void
*
key
);
static
dictIterator
*
dict
Get
Iterator
(
dict
*
ht
);
static
void
dictI
nitI
terator
(
dictIterator
*
iter
,
dict
*
ht
);
static
dictEntry
*
dictNext
(
dictIterator
*
iter
);
static
void
dictReleaseIterator
(
dictIterator
*
iter
);
#endif
/* __DICT_H */
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