From 704b112c38a68f021f8e98cafaf1a60257ea8c80 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 16 Mar 2010 03:04:17 +0100 Subject: Document internal make_strings_list() and change parameter names --- src/afc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/afc.c') 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) return nulls; } -static char **make_strings_list(char *tokens, uint32_t true_length) +/** + * Splits a string of tokens by null characters and returns each token in a + * char array/list. + * + * @param tokens The characters to split into a list. + * @param length The length of the tokens string. + * + * @return A char ** list with each token found in the string. The caller is + * responsible for freeing the memory. + */ +static char **make_strings_list(char *tokens, uint32_t length) { uint32_t nulls = 0, i = 0, j = 0; char **list = NULL; - if (!tokens || !true_length) + if (!tokens || !length) return NULL; - nulls = count_nullspaces(tokens, true_length); + nulls = count_nullspaces(tokens, length); list = (char **) malloc(sizeof(char *) * (nulls + 1)); for (i = 0; i < nulls; i++) { list[i] = strdup(tokens + j); -- cgit v1.1-32-gdbae