summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--async.c20
-rw-r--r--dict.c11
-rw-r--r--dict.h3
3 files changed, 9 insertions, 25 deletions
diff --git a/async.c b/async.c
index 074b46e..dd78dda 100644
--- a/async.c
+++ b/async.c
@@ -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);
}
diff --git a/dict.c b/dict.c
index 34a33ea..ad57181 100644
--- a/dict.c
+++ b/dict.c
@@ -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 */
diff --git a/dict.h b/dict.h
index 95fcd28..6ad0acd 100644
--- a/dict.h
+++ b/dict.h
@@ -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 *dictGetIterator(dict *ht);
+static void dictInitIterator(dictIterator *iter, dict *ht);
static dictEntry *dictNext(dictIterator *iter);
-static void dictReleaseIterator(dictIterator *iter);
#endif /* __DICT_H */