MCPcopy Create free account
hub / github.com/F-Stack/f-stack / autoMemoryAdd

Function autoMemoryAdd

app/redis-6.2.6/src/module.c:1044–1054  ·  view source on GitHub ↗

Add a new object to release automatically when the callback returns. */

Source from the content-addressed store, hash-verified

1042
1043/* Add a new object to release automatically when the callback returns. */
1044void 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.

Callers 15

RM_CreateStringFunction · 0.85
RM_CreateStringPrintfFunction · 0.85
RM_HoldStringFunction · 0.85
RM_GetClientUserNameByIdFunction · 0.85
RM_OpenKeyFunction · 0.85
RM_RandomKeyFunction · 0.85
RM_ListPopFunction · 0.85
RM_HashGetFunction · 0.85

Calls 1

zreallocFunction · 0.85

Tested by

no test coverage detected