summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/afc.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/afc.c b/src/afc.c
index e2e84e2..e966fa5 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -383,15 +383,25 @@ static uint32_t count_nullspaces(char *string, uint32_t number)
383 return nulls; 383 return nulls;
384} 384}
385 385
386static char **make_strings_list(char *tokens, uint32_t true_length) 386/**
387 * Splits a string of tokens by null characters and returns each token in a
388 * char array/list.
389 *
390 * @param tokens The characters to split into a list.
391 * @param length The length of the tokens string.
392 *
393 * @return A char ** list with each token found in the string. The caller is
394 * responsible for freeing the memory.
395 */
396static char **make_strings_list(char *tokens, uint32_t length)
387{ 397{
388 uint32_t nulls = 0, i = 0, j = 0; 398 uint32_t nulls = 0, i = 0, j = 0;
389 char **list = NULL; 399 char **list = NULL;
390 400
391 if (!tokens || !true_length) 401 if (!tokens || !length)
392 return NULL; 402 return NULL;
393 403
394 nulls = count_nullspaces(tokens, true_length); 404 nulls = count_nullspaces(tokens, length);
395 list = (char **) malloc(sizeof(char *) * (nulls + 1)); 405 list = (char **) malloc(sizeof(char *) * (nulls + 1));
396 for (i = 0; i < nulls; i++) { 406 for (i = 0; i < nulls; i++) {
397 list[i] = strdup(tokens + j); 407 list[i] = strdup(tokens + j);