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

Function autoMemoryCollect

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

Release all the objects in queue. */

Source from the content-addressed store, hash-verified

1090
1091/* Release all the objects in queue. */
1092void 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

Callers 1

moduleFreeContextFunction · 0.85

Calls 6

decrRefCountFunction · 0.85
RM_FreeCallReplyFunction · 0.85
RM_CloseKeyFunction · 0.85
RM_FreeDictFunction · 0.85
RM_FreeServerInfoFunction · 0.85
zfreeFunction · 0.70

Tested by

no test coverage detected