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

Function getInfoField

src/redis-cli.c:6812–6826  ·  view source on GitHub ↗

Return the specified INFO field from the INFO command output "info". * A new buffer is allocated for the result, that needs to be free'd. * If the field is not found NULL is returned. */

Source from the content-addressed store, hash-verified

6810 * A new buffer is allocated for the result, that needs to be free'd.
6811 * If the field is not found NULL is returned. */
6812static char *getInfoField(char *info, char *field) {
6813 char *p = strstr(info,field);
6814 char *n1, *n2;
6815 char *result;
6816
6817 if (!p) return NULL;
6818 p += strlen(field)+1;
6819 n1 = strchr(p,'\r');
6820 n2 = strchr(p,',');
6821 if (n2 && n2 < n1) n1 = n2;
6822 result = zmalloc(sizeof(char)*(n1-p)+1, MALLOC_LOCAL);
6823 memcpy(result,p,(n1-p));
6824 result[n1-p] = '\0';
6825 return result;
6826}
6827
6828/* Like the above function but automatically convert the result into
6829 * a long. On error (missing field) LONG_MIN is returned. */

Callers 1

getLongInfoFieldFunction · 0.85

Calls 1

zmallocFunction · 0.85

Tested by

no test coverage detected