MCPcopy Create free account
hub / github.com/apache/cloudberry / parse_comma_separated_list

Function parse_comma_separated_list

src/interfaces/libpq/fe-connect.c:1058–1085  ·  view source on GitHub ↗

* Parse a simple comma-separated list. * * On each call, returns a malloc'd copy of the next element, and sets *more * to indicate whether there are any more elements in the list after this, * and updates *startptr to point to the next element, if any. * * On out of memory, returns NULL. */

Source from the content-addressed store, hash-verified

1056 * On out of memory, returns NULL.
1057 */
1058static char *
1059parse_comma_separated_list(char **startptr, bool *more)
1060{
1061 char *p;
1062 char *s = *startptr;
1063 char *e;
1064 int len;
1065
1066 /*
1067 * Search for the end of the current element; a comma or end-of-string
1068 * acts as a terminator.
1069 */
1070 e = s;
1071 while (*e != '\0' && *e != ',')
1072 ++e;
1073 *more = (*e == ',');
1074
1075 len = e - s;
1076 p = (char *) malloc(sizeof(char) * (len + 1));
1077 if (p)
1078 {
1079 memcpy(p, s, len);
1080 p[len] = '\0';
1081 }
1082 *startptr = e + 1;
1083
1084 return p;
1085}
1086
1087/*
1088 * connectOptions2

Callers 1

connectOptions2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected