From 4506270136e8fd455a4709f854dd6d50920cb59e Mon Sep 17 00:00:00 2001 From: Meir Shpilraien Date: Tue, 3 Sep 2024 09:13:29 +0300 Subject: [PATCH] Review fixes --- src/dict.h | 12 ++++++++++++ src/module.c | 18 +++--------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/dict.h b/src/dict.h index 1c0e6accd32..e7883306631 100644 --- a/src/dict.h +++ b/src/dict.h @@ -257,6 +257,18 @@ dictStats* dictGetStatsHt(dict *d, int htidx, int full); void dictCombineStats(dictStats *from, dictStats *into); void dictFreeStats(dictStats *stats); +#define dictForEach(d, ty, m, ...) do { \ + dictIterator *di = dictGetIterator(d); \ + dictEntry *de; \ + while ((de = dictNext(di)) != NULL) { \ + ty *m = dictGetVal(de); \ + do { \ + __VA_ARGS__ \ + } while(0); \ + } \ + dictReleaseIterator(di); \ +} while(0); + #ifdef REDIS_TEST int dictTest(int argc, char *argv[], int flags); #endif diff --git a/src/module.c b/src/module.c index 61bee0843b0..79d494f8a05 100644 --- a/src/module.c +++ b/src/module.c @@ -13644,21 +13644,9 @@ int moduleDefragValue(robj *key, robj *value, int dbid) { return 1; } -#define modulesForEach(...) do { \ - dictIterator *di = dictGetIterator(modules); \ - dictEntry *de; \ - while ((de = dictNext(di)) != NULL) { \ - struct RedisModule *module = dictGetVal(de); \ - do { \ - __VA_ARGS__ \ - } while(0); \ - } \ - dictReleaseIterator(di); \ -} while(0); - /* Call registered module API defrag functions */ void moduleDefragGlobals(void) { - modulesForEach( + dictForEach(modules, struct RedisModule, module, if (module->defrag_cb) { RedisModuleDefragCtx defrag_ctx = { 0, NULL, NULL, -1}; module->defrag_cb(&defrag_ctx); @@ -13668,7 +13656,7 @@ void moduleDefragGlobals(void) { /* Call registered module API defrag start functions */ void moduleDefragStart(void) { - modulesForEach( + dictForEach(modules, struct RedisModule, module, if (module->defrag_start_cb) { RedisModuleDefragCtx defrag_ctx = { 0, NULL, NULL, -1}; module->defrag_start_cb(&defrag_ctx); @@ -13678,7 +13666,7 @@ void moduleDefragStart(void) { /* Call registered module API defrag end functions */ void moduleDefragEnd(void) { - modulesForEach( + dictForEach(modules, struct RedisModule, module, if (module->defrag_end_cb) { RedisModuleDefragCtx defrag_ctx = { 0, NULL, NULL, -1}; module->defrag_end_cb(&defrag_ctx);