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

parent a5f46d80
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "lxc.h" #include "lxc.h"
#include "monitor.h" #include "monitor.h"
#include "start.h" #include "start.h"
#include "utils.h"
lxc_log_define(state, lxc); lxc_log_define(state, lxc);
...@@ -78,16 +79,15 @@ lxc_state_t lxc_getstate(const char *name, const char *lxcpath) ...@@ -78,16 +79,15 @@ lxc_state_t lxc_getstate(const char *name, const char *lxcpath)
static int fillwaitedstates(const char *strstates, lxc_state_t *states) static int fillwaitedstates(const char *strstates, lxc_state_t *states)
{ {
char *token, *saveptr = NULL; char *token;
char *strstates_dup = strdup(strstates); char *strstates_dup;
int state; int state;
strstates_dup = strdup(strstates);
if (!strstates_dup) if (!strstates_dup)
return -1; return -1;
token = strtok_r(strstates_dup, "|", &saveptr); lxc_iterate_parts(token, strstates_dup, "|") {
while (token) {
state = lxc_str2state(token); state = lxc_str2state(token);
if (state < 0) { if (state < 0) {
free(strstates_dup); free(strstates_dup);
...@@ -95,8 +95,6 @@ static int fillwaitedstates(const char *strstates, lxc_state_t *states) ...@@ -95,8 +95,6 @@ static int fillwaitedstates(const char *strstates, lxc_state_t *states)
} }
states[state] = 1; states[state] = 1;
token = strtok_r(NULL, "|", &saveptr);
} }
free(strstates_dup); free(strstates_dup);
return 0; return 0;
......
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