+/*
+ * Creates a null-terminated array of strings, made by splitting the entries in
+ * @str on each @sep. Caller is responsible for calling free_string_list.
+ */
+static char **make_string_list(const char *str, const char *sep)
+{
+ char *copy, *tok;
+ char *saveptr = NULL;
+ char **clist = NULL;
+
+ copy = must_copy_string(str);
+
+ for (tok = strtok_r(copy, sep, &saveptr); tok;
+ tok = strtok_r(NULL, sep, &saveptr))
+ must_add_to_list(&clist, tok);
+
+ free(copy);
+
+ return clist;
+}
+
+/* Gets the length of a null-terminated array of strings. */
+static size_t string_list_length(char **list)
+{
+ size_t len = 0;
+ char **it;
+
+ for (it = list; it && *it; it++)
+ len++;
+
+ return len;
+}
+