tools: s/strtok_r()/lxc_iterate_parts()/g

parent eb29852f
...@@ -194,8 +194,6 @@ static struct lxc_list *accumulate_list(char *input, char *delimiter, ...@@ -194,8 +194,6 @@ static struct lxc_list *accumulate_list(char *input, char *delimiter,
static struct lxc_list *get_list(char *input, char *delimiter) static struct lxc_list *get_list(char *input, char *delimiter)
{ {
char *workstr = NULL; char *workstr = NULL;
char *workptr = NULL;
char *sptr = NULL;
char *token = NULL; char *token = NULL;
struct lxc_list *worklist; struct lxc_list *worklist;
struct lxc_list *workstr_list; struct lxc_list *workstr_list;
...@@ -212,11 +210,7 @@ static struct lxc_list *get_list(char *input, char *delimiter) ...@@ -212,11 +210,7 @@ static struct lxc_list *get_list(char *input, char *delimiter)
return NULL; return NULL;
} }
for (workptr = workstr;; workptr = NULL) { lxc_iterate_parts(token, workstr, delimiter) {
token = strtok_r(workptr, delimiter, &sptr);
if (!token)
break;
worklist = malloc(sizeof(*worklist)); worklist = malloc(sizeof(*worklist));
if (!worklist) if (!worklist)
break; break;
......
...@@ -209,10 +209,8 @@ static bool do_destroy_with_snapshots(struct lxc_container *c) ...@@ -209,10 +209,8 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
char *buf = NULL; char *buf = NULL;
char *lxcpath = NULL; char *lxcpath = NULL;
char *lxcname = NULL; char *lxcname = NULL;
char *scratch = NULL;
int fd; int fd;
int ret; int ret;
int counter = 0;
/* Destroy clones. */ /* Destroy clones. */
ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name); ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name);
...@@ -244,15 +242,10 @@ static bool do_destroy_with_snapshots(struct lxc_container *c) ...@@ -244,15 +242,10 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
} }
close(fd); close(fd);
while ((lxcpath = strtok_r(!counter ? buf : NULL, "\n", &scratch))) { lxc_iterate_parts(lxcpath, buf, "\n") {
if (!(lxcname = strtok_r(NULL, "\n", &scratch)))
break;
c1 = lxc_container_new(lxcname, lxcpath); c1 = lxc_container_new(lxcname, lxcpath);
if (!c1) { if (!c1)
counter++;
continue; continue;
}
/* We do not destroy recursively. If a clone of a clone /* We do not destroy recursively. If a clone of a clone
* has clones or snapshots the user should remove it * has clones or snapshots the user should remove it
...@@ -264,7 +257,6 @@ static bool do_destroy_with_snapshots(struct lxc_container *c) ...@@ -264,7 +257,6 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
} }
lxc_container_put(c1); lxc_container_put(c1);
counter++;
} }
free(buf); free(buf);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment