]> Dogcows Code - chaz/openbox/blobdiff - obt/paths.c
make array large enough
[chaz/openbox] / obt / paths.c
index 6100499893e306a3dce92cd1fd041f49c20c85c2..da6f288bf6cf9fd62abca6bedf02c279ff7b6bba 100644 (file)
@@ -80,7 +80,7 @@ ObtPaths* obt_paths_new(void)
     ObtPaths *p;
     const gchar *path;
 
-    p = g_new0(ObtPaths, 1);
+    p = g_slice_new0(ObtPaths);
     p->ref = 1;
 
     path = g_getenv("XDG_CONFIG_HOME");
@@ -163,20 +163,22 @@ void obt_paths_unref(ObtPaths *p)
         g_free(p->data_home);
         g_free(p->cache_home);
 
-        obt_free0(p, ObtPaths, 1);
+        g_slice_free(ObtPaths, p);
     }
 }
 
 gchar *obt_paths_expand_tilde(const gchar *f)
 {
-    gchar **spl;
     gchar *ret;
+    GRegex *regex;
 
     if (!f)
         return NULL;
-    spl = g_strsplit(f, "~", 0);
-    ret = g_strjoinv(g_get_home_dir(), spl);
-    g_strfreev(spl);
+
+    regex = g_regex_new("(?:^|(?<=[ \\t]))~(?=[/ \\t$])", G_REGEX_MULTILINE | G_REGEX_RAW, 0, NULL);
+    ret = g_regex_replace_literal(regex, f, -1, 0, g_get_home_dir(), 0, NULL);
+    g_regex_unref(regex);
+
     return ret;
 }
 
This page took 0.021427 seconds and 4 git commands to generate.