xt_inhale_strings(3)

NAME
xt_inhale_strings() - Read list of strings into array

LIBRARY
#include <xtend/file.h>
-lxtend

SYNOPSIS
ssize_t xt_inhale_strings(FILE *stream, char ***list)

ARGUMENTS
stream  FILE * from which strings are read, one per line
list    Pointer to a char ** (poiner array), populated with strings

DESCRIPTION
xt_inhale_strings() reads a list of strings from a file, one per line, into a pointer array. Memory is allocated for the pointer array and for each string. Memory should be freed using xt_free_strings(3) as soon as the strings are no longer needed. Inhaling large amounts of data into arrays should generally be avoided in favor of more memory-efficient use-once-and-discard strategies, but may be advantageous for small lists of strings accessed repeatedly, or necessary for a few tasks such as sorting.

RETURN VALUES
The number of strings read, XT_READ_IO_ERR on read error

EXAMPLES
FILE    *instream;
char    **strings;
ssize_t string_count;
string_count = xt_inhale_strings(instream, &strings);
xt_free_strings(strings);

SEE ALSO
xt_free_strings(3)