static struct lxc_list *get_list(char *input, char *delimiter)
{
char *workstr = NULL;
- char *workptr = NULL;
- char *sptr = NULL;
char *token = NULL;
struct lxc_list *worklist;
struct lxc_list *workstr_list;
return NULL;
}
- for (workptr = workstr;; workptr = NULL) {
- token = strtok_r(workptr, delimiter, &sptr);
- if (!token)
- break;
-
+ lxc_iterate_parts(token, workstr, delimiter) {
worklist = malloc(sizeof(*worklist));
if (!worklist)
break;
char *buf = NULL;
char *lxcpath = NULL;
char *lxcname = NULL;
- char *scratch = NULL;
int fd;
int ret;
- int counter = 0;
/* Destroy clones. */
ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name);
}
close(fd);
- while ((lxcpath = strtok_r(!counter ? buf : NULL, "\n", &scratch))) {
- if (!(lxcname = strtok_r(NULL, "\n", &scratch)))
- break;
-
+ lxc_iterate_parts(lxcpath, buf, "\n") {
c1 = lxc_container_new(lxcname, lxcpath);
- if (!c1) {
- counter++;
+ if (!c1)
continue;
- }
/* We do not destroy recursively. If a clone of a clone
* has clones or snapshots the user should remove it
}
lxc_container_put(c1);
- counter++;
}
free(buf);
}