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

Function moduleCreateCallReplyFromProto

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

Create a new RedisModuleCallReply object. The processing of the reply * is lazy, the object is just populated with the raw protocol and later * is processed as needed. Initially we just make sure to set the right * reply type, which is extremely cheap to do. */

Source from the content-addressed store, hash-verified

3755 * is processed as needed. Initially we just make sure to set the right
3756 * reply type, which is extremely cheap to do. */
3757RedisModuleCallReply *moduleCreateCallReplyFromProto(RedisModuleCtx *ctx, sds proto) {
3758 RedisModuleCallReply *reply = zmalloc(sizeof(*reply));
3759 reply->ctx = ctx;
3760 reply->proto = proto;
3761 reply->protolen = sdslen(proto);
3762 reply->flags = REDISMODULE_REPLYFLAG_TOPARSE; /* Lazy parsing. */
3763 switch(proto[0]) {
3764 case '$':
3765 case '+': reply->type = REDISMODULE_REPLY_STRING; break;
3766 case '-': reply->type = REDISMODULE_REPLY_ERROR; break;
3767 case ':': reply->type = REDISMODULE_REPLY_INTEGER; break;
3768 case '*': reply->type = REDISMODULE_REPLY_ARRAY; break;
3769 default: reply->type = REDISMODULE_REPLY_UNKNOWN; break;
3770 }
3771 if ((proto[0] == '*' || proto[0] == '$') && proto[1] == '-')
3772 reply->type = REDISMODULE_REPLY_NULL;
3773 return reply;
3774}
3775
3776void moduleParseCallReply_Int(RedisModuleCallReply *reply);
3777void moduleParseCallReply_BulkString(RedisModuleCallReply *reply);

Callers 1

RM_CallFunction · 0.85

Calls 2

zmallocFunction · 0.85
sdslenFunction · 0.85

Tested by

no test coverage detected