207 tmp =
rtalloc(
sizeof(
char) * (strlen(str) + 1));
209 rterror(
_(
"strsplit: Not enough memory"));
214 if (!strlen(tmp) || !delimiter || !strlen(delimiter)) {
216 rtn = (
char **)
rtalloc(*n *
sizeof(
char *));
218 rterror(
_(
"strsplit: Not enough memory"));
221 rtn[0] = (
char *)
rtalloc(
sizeof(
char) * (strlen(tmp) + 1));
222 if (NULL == rtn[0]) {
223 rterror(
_(
"strsplit: Not enough memory"));
231 token = strtok(tmp, delimiter);
232 while (token != NULL) {
234 rtn = (
char **)
rtalloc(
sizeof(
char *));
237 rtn = (
char **)
rtrealloc(rtn, (*n + 1) *
sizeof(
char *));
240 rterror(
_(
"strsplit: Not enough memory"));
245 rtn[*n] = (
char *)
rtalloc(
sizeof(
char) * (strlen(token) + 1));
246 if (NULL == rtn[*n]) {
247 rterror(
_(
"strsplit: Not enough memory"));
251 strcpy(rtn[*n], token);
254 token = strtok(NULL, delimiter);
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
void * rtrealloc(void *mem, size_t size)
void rtdealloc(void *mem)