diff options
author | Bjorn Svensson <bjorn.a.svensson@est.tech> | 2021-01-25 15:43:40 +0100 |
---|---|---|
committer | Bjorn Svensson <bjorn.a.svensson@est.tech> | 2021-01-25 16:19:42 +0100 |
commit | 920128a260b0056f7b14b479232d96405d9a6e62 (patch) | |
tree | 557b0ecafd965e21e96cadedcc51c4ec647c6f99 /async.c | |
parent | 297ecbecb71616977ab0bb9b7387d8fa19a5a54f (diff) |
Stack allocate dict iterators
Replacing the get & release functions with an initiation
function. Simplifies the code and will make sure we
run subscription callbacks in OOM scenarios.
Diffstat (limited to 'async.c')
-rw-r--r-- | async.c | 20 |
1 files changed, 7 insertions, 13 deletions
@@ -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) - __redisRunCallback(ac,dictGetEntryVal(de),NULL); - dictReleaseIterator(it); - } + dictInitIterator(&it,ac->sub.channels); + while ((de = dictNext(&it)) != NULL) + __redisRunCallback(ac,dictGetEntryVal(de),NULL); dictRelease(ac->sub.channels); } if (ac->sub.patterns) { - it = dictGetIterator(ac->sub.patterns); - if (it != NULL) { - while ((de = dictNext(it)) != NULL) - __redisRunCallback(ac,dictGetEntryVal(de),NULL); - dictReleaseIterator(it); - } + dictInitIterator(&it,ac->sub.patterns); + while ((de = dictNext(&it)) != NULL) + __redisRunCallback(ac,dictGetEntryVal(de),NULL); dictRelease(ac->sub.patterns); } |