Add a new object to release automatically when the callback returns. */
| 1069 | |
| 1070 | /* Add a new object to release automatically when the callback returns. */ |
| 1071 | void autoMemoryAdd(RedisModuleCtx *ctx, int type, void *ptr) { |
| 1072 | if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return; |
| 1073 | if (ctx->amqueue_used == ctx->amqueue_len) { |
| 1074 | ctx->amqueue_len *= 2; |
| 1075 | if (ctx->amqueue_len < 16) ctx->amqueue_len = 16; |
| 1076 | ctx->amqueue = (AutoMemEntry*)zrealloc(ctx->amqueue,sizeof(struct AutoMemEntry)*ctx->amqueue_len, MALLOC_LOCAL); |
| 1077 | } |
| 1078 | ctx->amqueue[ctx->amqueue_used].type = type; |
| 1079 | ctx->amqueue[ctx->amqueue_used].ptr = ptr; |
| 1080 | ctx->amqueue_used++; |
| 1081 | } |
| 1082 | |
| 1083 | /* Mark an object as freed in the auto release queue, so that users can still |
| 1084 | * free things manually if they want. |
no test coverage detected