Add a new object to release automatically when the callback returns. */
| 1042 | |
| 1043 | /* Add a new object to release automatically when the callback returns. */ |
| 1044 | void autoMemoryAdd(RedisModuleCtx *ctx, int type, void *ptr) { |
| 1045 | if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return; |
| 1046 | if (ctx->amqueue_used == ctx->amqueue_len) { |
| 1047 | ctx->amqueue_len *= 2; |
| 1048 | if (ctx->amqueue_len < 16) ctx->amqueue_len = 16; |
| 1049 | ctx->amqueue = zrealloc(ctx->amqueue,sizeof(struct AutoMemEntry)*ctx->amqueue_len); |
| 1050 | } |
| 1051 | ctx->amqueue[ctx->amqueue_used].type = type; |
| 1052 | ctx->amqueue[ctx->amqueue_used].ptr = ptr; |
| 1053 | ctx->amqueue_used++; |
| 1054 | } |
| 1055 | |
| 1056 | /* Mark an object as freed in the auto release queue, so that users can still |
| 1057 | * free things manually if they want. |
no test coverage detected