2 #include "talloc/talloc.h"
5 /* This is a dumb one which copies. We could mangle instead. */
6 char **split(const void *ctx, const char *text, const char *delims,
10 unsigned int max = 64, num = 0;
12 lines = talloc_array(ctx, char *, max+1);
14 while (*text != '\0') {
15 unsigned int len = strcspn(text, delims);
16 lines[num] = talloc_array(lines, char, len + 1);
17 memcpy(lines[num], text, len);
18 lines[num][len] = '\0';
20 text += strspn(text, delims);
22 lines = talloc_realloc(ctx, lines, char *, max*=2 + 1);