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

Function moduleFreeCallReplyRec

src/module.cpp:3952–3975  ·  view source on GitHub ↗

Recursive free reply function. */

Source from the content-addressed store, hash-verified

3950
3951/* Recursive free reply function. */
3952void moduleFreeCallReplyRec(RedisModuleCallReply *reply, int freenested){
3953 /* Don't free nested replies by default: the user must always free the
3954 * toplevel reply. However be gentle and don't crash if the module
3955 * misuses the API. */
3956 if (!freenested && reply->flags & REDISMODULE_REPLYFLAG_NESTED) return;
3957
3958 if (!(reply->flags & REDISMODULE_REPLYFLAG_TOPARSE)) {
3959 if (reply->type == REDISMODULE_REPLY_ARRAY) {
3960 size_t j;
3961 for (j = 0; j < reply->len; j++)
3962 moduleFreeCallReplyRec(reply->val.array+j,1);
3963 zfree(reply->val.array);
3964 }
3965 }
3966
3967 /* For nested replies, we don't free reply->proto (which if not NULL
3968 * references the parent reply->proto buffer), nor the structure
3969 * itself which is allocated as an array of structures, and is freed
3970 * when the array value is released. */
3971 if (!(reply->flags & REDISMODULE_REPLYFLAG_NESTED)) {
3972 if (reply->proto) sdsfree(reply->proto);
3973 zfree(reply);
3974 }
3975}
3976
3977/* Free a Call reply and all the nested replies it contains if it's an
3978 * array. */

Callers 1

RM_FreeCallReplyFunction · 0.85

Calls 2

zfreeFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected