]> Dogcows Code - chaz/openbox/commitdiff
use g_strsplit to save work
authorDana Jansens <danakj@orodu.net>
Wed, 15 Oct 2003 03:11:59 +0000 (03:11 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 15 Oct 2003 03:11:59 +0000 (03:11 +0000)
parser/parse.c

index a791073bfc1eddd5ea08a38bb5dd68130967987a..de7bba6eca536311aa37acd0765fbcf1b71cc40d 100644 (file)
@@ -262,20 +262,14 @@ gboolean parse_attr_contains(const char *val, xmlNodePtr node,
 static GSList* split_paths(const gchar *paths)
 {
     GSList *list = NULL;
-    gchar *c, *e, *s;
+    gchar **spl, **it;
 
-    c = g_strdup(paths);
-    s = c;
-    e = c - 1;
-    while ((e = strchr(e + 1, ':'))) {
-        *e = '\0';
-        if (s[0] != '\0')
-            list = g_slist_append(list, g_strdup(s));
-        s = e + 1;
-    }
-    if (s[0] != '\0')
-        list = g_slist_append(list, g_strdup(s));
-    g_free(c);
+    if (!paths)
+        return NULL;
+    spl = g_strsplit(paths, ":", -1);
+    for (it = spl; *it; ++it)
+        list = g_slist_append(list, *it);
+    g_free(spl);
     return list;
 }
 
This page took 0.025066 seconds and 4 git commands to generate.