From 074e28a46eb2646ab33002731fac6b4fc223b0bb Mon Sep 17 00:00:00 2001 From: sundb Date: Mon, 26 Apr 2021 21:30:34 +0800 Subject: [PATCH] Simplify rax free for RM_FreeServerInfo (#8866) --- src/module.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/module.c b/src/module.c index 2cc071e62..995312a74 100644 --- a/src/module.c +++ b/src/module.c @@ -7101,16 +7101,7 @@ RedisModuleServerInfoData *RM_GetServerInfo(RedisModuleCtx *ctx, const char *sec * context instead of passing NULL. */ void RM_FreeServerInfo(RedisModuleCtx *ctx, RedisModuleServerInfoData *data) { if (ctx != NULL) autoMemoryFreed(ctx,REDISMODULE_AM_INFO,data); - raxIterator ri; - raxStart(&ri,data->rax); - while(1) { - raxSeek(&ri,"^",NULL,0); - if (!raxNext(&ri)) break; - raxRemove(data->rax,(unsigned char*)ri.key,ri.key_len,NULL); - sdsfree(ri.data); - } - raxStop(&ri); - raxFree(data->rax); + raxFreeWithCallback(data->rax, (void(*)(void*))sdsfree); zfree(data); }