152 tmp = palloc(
sizeof(
char) * (strlen(str) + 1));
154 fprintf(stderr,
"Not enough memory\n");
159 if (!strlen(tmp) || !delimiter || !strlen(delimiter)) {
161 rtn = (
char **) palloc(*n *
sizeof(
char *));
163 fprintf(stderr,
"Not enough memory\n");
166 rtn[0] = (
char *) palloc(
sizeof(
char) * (strlen(tmp) + 1));
167 if (NULL == rtn[0]) {
168 fprintf(stderr,
"Not enough memory\n");
176 token = strtok(tmp, delimiter);
177 while (token != NULL) {
179 rtn = (
char **) palloc(
sizeof(
char *));
182 rtn = (
char **) repalloc(rtn, (*n + 1) *
sizeof(
char *));
185 fprintf(stderr,
"Not enough memory\n");
190 rtn[*n] = (
char *) palloc(
sizeof(
char) * (strlen(token) + 1));
191 if (NULL == rtn[*n]) {
192 fprintf(stderr,
"Not enough memory\n");
196 strcpy(rtn[*n], token);
199 token = strtok(NULL, delimiter);