commit 5c204376213ec37399d68aca4abd0abfea2366bd
parent 46a8a5c02498c1a886aa2242ef5438ca7cc017cf
Author: Christoph Lohmann <20h@r-36.net>
Date: Sun, 5 Aug 2012 07:02:28 +0200
Use strtok_r instead of strtok.
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/llist.c b/llist.c
@@ -648,12 +648,14 @@ llist_listadd(llist_t *llist, llist_t *elems)
llist_t *
llist_splitstr(char *str, char *sep)
{
- char *tok, *strc;
+ char *tok, *strc, *saveptr;
llist_t *llist;
+ saveptr = NULL;
+
strc = memdup(str, strlen(str)+1);
- tok = strtok(strc, sep);
+ tok = strtok_r(strc, sep, &saveptr);
if (tok == NULL) {
free(strc);
return NULL;
@@ -662,7 +664,7 @@ llist_splitstr(char *str, char *sep)
llist = llist_new();
do {
llist_add(llist, tok, NULL, 0);
- } while((tok = strtok(NULL, sep)));
+ } while((tok = strtok_r(NULL, sep, &saveptr)));
free(strc);
return llist;