Release all the objects in queue. */
| 1090 | |
| 1091 | /* Release all the objects in queue. */ |
| 1092 | void autoMemoryCollect(RedisModuleCtx *ctx) { |
| 1093 | if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return; |
| 1094 | /* Clear the AUTO_MEMORY flag from the context, otherwise the functions |
| 1095 | * we call to free the resources, will try to scan the auto release |
| 1096 | * queue to mark the entries as freed. */ |
| 1097 | ctx->flags &= ~REDISMODULE_CTX_AUTO_MEMORY; |
| 1098 | int j; |
| 1099 | for (j = 0; j < ctx->amqueue_used; j++) { |
| 1100 | void *ptr = ctx->amqueue[j].ptr; |
| 1101 | switch(ctx->amqueue[j].type) { |
| 1102 | case REDISMODULE_AM_STRING: decrRefCount(ptr); break; |
| 1103 | case REDISMODULE_AM_REPLY: RM_FreeCallReply(ptr); break; |
| 1104 | case REDISMODULE_AM_KEY: RM_CloseKey(ptr); break; |
| 1105 | case REDISMODULE_AM_DICT: RM_FreeDict(NULL,ptr); break; |
| 1106 | case REDISMODULE_AM_INFO: RM_FreeServerInfo(NULL,ptr); break; |
| 1107 | } |
| 1108 | } |
| 1109 | ctx->flags |= REDISMODULE_CTX_AUTO_MEMORY; |
| 1110 | zfree(ctx->amqueue); |
| 1111 | ctx->amqueue = NULL; |
| 1112 | ctx->amqueue_len = 0; |
| 1113 | ctx->amqueue_used = 0; |
| 1114 | } |
| 1115 | |
| 1116 | /* -------------------------------------------------------------------------- |
| 1117 | * ## String objects APIs |
no test coverage detected