summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/compcore.c21
-rw-r--r--Src/Zle/computil.c19
2 files changed, 5 insertions, 35 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 3e4f690f3..348054e86 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -644,7 +644,7 @@ callcompfunc(char *s, char *fn)
 	if (compredirs)
 	    freearray(compredirs);
         if (rdstrs)
-            compredirs = bld_list_array(rdstrs);
+            compredirs = zlinklist2array(rdstrs);
         else
             compredirs = (char **) zshcalloc(sizeof(char *));
 
@@ -1852,30 +1852,13 @@ set_comp_sep(void)
     return 0;
 }
 
-/* This builds an array from a list of strings. */
-
-/**/
-mod_export char **
-bld_list_array(LinkList l)
-{
-    char **a, **p;
-    LinkNode n;
-
-    a = (char **) zalloc((countlinknodes(l) + 1) * sizeof(char *));
-    for (p = a, n = firstnode(l); n; incnode(n))
-	*p++ = ztrdup((char *) getdata(n));
-    *p = NULL;
-
-    return a;
-}
-
 /* This stores the strings from the list in an array. */
 
 /**/
 mod_export void
 set_list_array(char *name, LinkList l)
 {
-    setaparam(name, bld_list_array(l));
+    setaparam(name, zlinklist2array(l));
 }
 
 /* Get the words from a variable or a (list of words). */
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 0d8cf5364..b9df1e418 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -3406,16 +3406,9 @@ bin_compvalues(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
         /* Again, as for comparguments.  This returns the values and their
          * arguments as an array which will be stored in val_args in _values. */
 	if (cv_laststate.vals) {
-	    char **ret, **p;
-	    LinkNode n;
-
-	    ret = (char **) zalloc((countlinknodes(cv_laststate.vals) + 1) *
-				   sizeof(char *));
-
-	    for (n = firstnode(cv_laststate.vals), p = ret; n; incnode(n), p++)
-		*p = ztrdup((char *) getdata(n));
-	    *p = NULL;
+	    char **ret;
 
+	    ret = zlinklist2array(cv_laststate.vals);
 	    sethparam(args[1], ret);
 
 	    return 0;
@@ -3738,7 +3731,6 @@ bin_comptry(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
 	if (!strcmp(*args, "-m")) {
 	    char *s, *p, *q, *c, **all = comptags[lasttaglevel]->all;
 	    LinkList list = newlinklist();
-	    LinkNode node;
 	    int num = 0;
 	    Ctset set;
 
@@ -3833,16 +3825,11 @@ bin_comptry(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
 		    }
 		}
 		if (num) {
-		    char **a;
 		    Ctset l;
 
 		    set = (Ctset) zalloc(sizeof(*set));
 
-		    a = set->tags = (char **) zalloc((num + 1) * sizeof(char *));
-		    for (node = firstnode(list); node; incnode(node))
-			*a++ = ztrdup((char *) getdata(node));
-
-		    *a = NULL;
+		    set->tags = zlinklist2array(list);
 		    set->next = NULL;
 		    set->ptr = NULL;
 		    set->tag = NULL;