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

Function getInfoField

app/redis-6.2.6/src/redis-cli.c:7926–7940  ·  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

7924 * A new buffer is allocated for the result, that needs to be free'd.
7925 * If the field is not found NULL is returned. */
7926static char *getInfoField(char *info, char *field) {
7927 char *p = strstr(info,field);
7928 char *n1, *n2;
7929 char *result;
7930
7931 if (!p) return NULL;
7932 p += strlen(field)+1;
7933 n1 = strchr(p,'\r');
7934 n2 = strchr(p,',');
7935 if (n2 && n2 < n1) n1 = n2;
7936 result = zmalloc(sizeof(char)*(n1-p)+1);
7937 memcpy(result,p,(n1-p));
7938 result[n1-p] = '\0';
7939 return result;
7940}
7941
7942/* Like the above function but automatically convert the result into
7943 * a long. On error (missing field) LONG_MIN is returned. */

Callers 1

getLongInfoFieldFunction · 0.85

Calls 4

strstrFunction · 0.85
strchrFunction · 0.85
zmallocFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected