8 #include "talloc/talloc.h"
10 char **strsplit(const void *ctx, const char *string, const char *delims,
14 unsigned int max = 64, num = 0;
16 lines = talloc_array(ctx, char *, max+1);
18 while (*string != '\0') {
19 unsigned int len = strcspn(string, delims);
20 lines[num] = talloc_array(lines, char, len + 1);
21 memcpy(lines[num], string, len);
22 lines[num][len] = '\0';
24 string += strspn(string, delims) ? 1 : 0;
26 lines = talloc_realloc(ctx, lines, char *, max*=2 + 1);
34 char *strjoin(const void *ctx, char *strings[], const char *delim)
37 char *ret = talloc_strdup(ctx, "");
39 for (i = 0; strings[i]; i++) {
40 ret = talloc_append_string(ret, strings[i]);
41 ret = talloc_append_string(ret, delim);