From 920128a260b0056f7b14b479232d96405d9a6e62 Mon Sep 17 00:00:00 2001 From: Bjorn Svensson Date: Mon, 25 Jan 2021 15:43:40 +0100 Subject: 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. --- dict.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'dict.c') 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 */ -- cgit v1.2.3