Release all the objects in queue. */
| 1117 | |
| 1118 | /* Release all the objects in queue. */ |
| 1119 | void autoMemoryCollect(RedisModuleCtx *ctx) { |
| 1120 | if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return; |
| 1121 | /* Clear the AUTO_MEMORY flag from the context, otherwise the functions |
| 1122 | * we call to free the resources, will try to scan the auto release |
| 1123 | * queue to mark the entries as freed. */ |
| 1124 | ctx->flags &= ~REDISMODULE_CTX_AUTO_MEMORY; |
| 1125 | int j; |
| 1126 | for (j = 0; j < ctx->amqueue_used; j++) { |
| 1127 | void *ptr = (robj*)ctx->amqueue[j].ptr; |
| 1128 | switch(ctx->amqueue[j].type) { |
| 1129 | case REDISMODULE_AM_STRING: decrRefCount((robj*)ptr); break; |
| 1130 | case REDISMODULE_AM_REPLY: RM_FreeCallReply((RedisModuleCallReply*)ptr); break; |
| 1131 | case REDISMODULE_AM_KEY: RM_CloseKey((RedisModuleKey*)ptr); break; |
| 1132 | case REDISMODULE_AM_DICT: RM_FreeDict(NULL,(RedisModuleDict*)ptr); break; |
| 1133 | case REDISMODULE_AM_INFO: RM_FreeServerInfo(NULL,(RedisModuleServerInfoData*)ptr); break; |
| 1134 | } |
| 1135 | } |
| 1136 | ctx->flags |= REDISMODULE_CTX_AUTO_MEMORY; |
| 1137 | zfree(ctx->amqueue); |
| 1138 | ctx->amqueue = NULL; |
| 1139 | ctx->amqueue_len = 0; |
| 1140 | ctx->amqueue_used = 0; |
| 1141 | } |
| 1142 | |
| 1143 | /* -------------------------------------------------------------------------- |
| 1144 | * ## String objects APIs |
no test coverage detected