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

Function cliInitHelp

src/redis-cli.c:329–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

327}
328
329static void cliInitHelp(void) {
330 int commandslen = sizeof(commandHelp)/sizeof(struct commandHelp);
331 int groupslen = sizeof(commandGroups)/sizeof(char*);
332 int i, len, pos = 0;
333 helpEntry tmp;
334
335 helpEntriesLen = len = commandslen+groupslen;
336 helpEntries = zmalloc(sizeof(helpEntry)*len, MALLOC_LOCAL);
337
338 for (i = 0; i < groupslen; i++) {
339 tmp.argc = 1;
340 tmp.argv = zmalloc(sizeof(sds), MALLOC_LOCAL);
341 tmp.argv[0] = sdscatprintf(sdsempty(),"@%s",commandGroups[i]);
342 tmp.full = tmp.argv[0];
343 tmp.type = CLI_HELP_GROUP;
344 tmp.org = NULL;
345 helpEntries[pos++] = tmp;
346 }
347
348 for (i = 0; i < commandslen; i++) {
349 tmp.argv = sdssplitargs(commandHelp[i].name,&tmp.argc);
350 tmp.full = sdsnew(commandHelp[i].name);
351 tmp.type = CLI_HELP_COMMAND;
352 tmp.org = &commandHelp[i];
353 helpEntries[pos++] = tmp;
354 }
355}
356
357/* cliInitHelp() setups the helpEntries array with the command and group
358 * names from the help.h file. However the Redis instance we are connecting

Callers 1

replFunction · 0.85

Calls 5

zmallocFunction · 0.85
sdscatprintfFunction · 0.85
sdsemptyFunction · 0.85
sdssplitargsFunction · 0.85
sdsnewFunction · 0.85

Tested by

no test coverage detected