Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MeirShpilraien committed Sep 3, 2024
1 parent b1db05e commit 4506270
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 12 additions & 0 deletions src/dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 3 additions & 15 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 4506270

Please sign in to comment.