]> git.ozlabs.org Git - ccan/blobdiff - ccan/string/string.c
strjoin()
[ccan] / ccan / string / string.c
index d3d17bbd3156eb065ece87e94f28810fddf7a465..b1de8eda915bbf3ee81fc2e9f1df96603eb6084b 100644 (file)
@@ -30,4 +30,15 @@ char **strsplit(const void *ctx, const char *string, const char *delims,
                *nump = num;
        return lines;
 }
-       
+
+char *strjoin(const void *ctx, char *strings[], const char *delim)
+{
+       unsigned int i;
+       char *ret = talloc_strdup(ctx, "");
+
+       for (i = 0; strings[i]; i++) {
+               ret = talloc_append_string(ret, strings[i]);
+               ret = talloc_append_string(ret, delim);
+       }
+       return ret;
+}