MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / autoMemoryAdd

Function autoMemoryAdd

src/module.cpp:1071–1081  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1069
1070/* Add a new object to release automatically when the callback returns. */
1071void 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.

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