210 tmp =
rtalloc(
sizeof(
char) * (strlen(
str) + 1));
212 rterror(
_(
"strsplit: Not enough memory"));
217 if (!strlen(tmp) || !delimiter || !strlen(delimiter)) {
219 rtn = (
char **)
rtalloc(*n *
sizeof(
char *));
221 rterror(
_(
"strsplit: Not enough memory"));
224 rtn[0] = (
char *)
rtalloc(
sizeof(
char) * (strlen(tmp) + 1));
225 if (NULL == rtn[0]) {
226 rterror(
_(
"strsplit: Not enough memory"));
234 token = strtok(tmp, delimiter);
235 while (token != NULL) {
237 rtn = (
char **)
rtalloc(
sizeof(
char *));
240 rtn = (
char **)
rtrealloc(rtn, (*n + 1) *
sizeof(
char *));
243 rterror(
_(
"strsplit: Not enough memory"));
248 rtn[*n] = (
char *)
rtalloc(
sizeof(
char) * (strlen(token) + 1));
249 if (NULL == rtn[*n]) {
250 rterror(
_(
"strsplit: Not enough memory"));
254 strcpy(rtn[*n], token);
257 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)