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 /dict.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 'dict.c')
-rw-r--r-- | dict.c | 11 |
1 files changed, 1 insertions, 10 deletions
@@ -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 */ |