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

Function RM_CreateStringPrintf

src/module.cpp:1171–1183  ·  view source on GitHub ↗

Create a new module string object from a printf format and arguments. * The returned string must be freed with RedisModule_FreeString(), unless * automatic memory is enabled. * * The string is created using the sds formatter function sdscatvprintf(). * * The passed context 'ctx' may be NULL if necessary, see the * RedisModule_CreateString() documentation for more info. */

Source from the content-addressed store, hash-verified

1169 * The passed context 'ctx' may be NULL if necessary, see the
1170 * RedisModule_CreateString() documentation for more info. */
1171RedisModuleString *RM_CreateStringPrintf(RedisModuleCtx *ctx, const char *fmt, ...) {
1172 sds s = sdsempty();
1173
1174 va_list ap;
1175 va_start(ap, fmt);
1176 s = sdscatvprintf(s, fmt, ap);
1177 va_end(ap);
1178
1179 RedisModuleString *o = createObject(OBJ_STRING, s);
1180 if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o);
1181
1182 return o;
1183}
1184
1185
1186/* Like RedisModule_CreatString(), but creates a string starting from a long long

Callers

nothing calls this directly

Calls 4

sdsemptyFunction · 0.85
sdscatvprintfFunction · 0.85
createObjectFunction · 0.85
autoMemoryAddFunction · 0.85

Tested by

no test coverage detected