summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/dmx/input/dmxarg.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/hw/dmx/input/dmxarg.c b/hw/dmx/input/dmxarg.c
index 6c21ae959..582ed3faa 100644
--- a/hw/dmx/input/dmxarg.c
+++ b/hw/dmx/input/dmxarg.c
@@ -114,30 +114,17 @@ dmxArgC(dmxArg a)
dmxArg
dmxArgParse(const char *string)
{
- char *tmp;
- char *start, *pt;
+ int i = 0;
dmxArg a = dmxArgCreate();
- int done;
- int len;
if (!string)
return a;
- len = strlen(string) + 2;
- tmp = malloc(len);
- strncpy(tmp, string, len);
-
- for (start = pt = tmp, done = 0; !done && *pt; start = ++pt) {
- for (; *pt && *pt != ','; pt++);
- if (!*pt)
- done = 1;
- *pt = '\0';
- dmxArgAdd(a, start);
- }
- if (!done)
- dmxArgAdd(a, ""); /* Final comma */
-
- free(tmp);
+ a->argv = (const char **)xstrtokenize(string, ",");
+ if (a->argv)
+ for (i = 0; a->argv[i] != NULL; i++);
+ a->argc = i;
+
return a;
}