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

Function moduleFreeCallReplyRec

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

Recursive free reply function. */

Source from the content-addressed store, hash-verified

3862
3863/* Recursive free reply function. */
3864void moduleFreeCallReplyRec(RedisModuleCallReply *reply, int freenested){
3865 /* Don't free nested replies by default: the user must always free the
3866 * toplevel reply. However be gentle and don't crash if the module
3867 * misuses the API. */
3868 if (!freenested && reply->flags & REDISMODULE_REPLYFLAG_NESTED) return;
3869
3870 if (!(reply->flags & REDISMODULE_REPLYFLAG_TOPARSE)) {
3871 if (reply->type == REDISMODULE_REPLY_ARRAY) {
3872 size_t j;
3873 for (j = 0; j < reply->len; j++)
3874 moduleFreeCallReplyRec(reply->val.array+j,1);
3875 zfree(reply->val.array);
3876 }
3877 }
3878
3879 /* For nested replies, we don't free reply->proto (which if not NULL
3880 * references the parent reply->proto buffer), nor the structure
3881 * itself which is allocated as an array of structures, and is freed
3882 * when the array value is released. */
3883 if (!(reply->flags & REDISMODULE_REPLYFLAG_NESTED)) {
3884 if (reply->proto) sdsfree(reply->proto);
3885 zfree(reply);
3886 }
3887}
3888
3889/* Free a Call reply and all the nested replies it contains if it's an
3890 * array. */

Callers 1

RM_FreeCallReplyFunction · 0.85

Calls 2

sdsfreeFunction · 0.85
zfreeFunction · 0.70

Tested by

no test coverage detected