FreeBSD Manual Pages
xt_read_line_malloc(3) Library Functions Manual xt_read_line_malloc(3) NAME xt_read_line_malloc() - Read a line and allocate memory for it LIBRARY #include <xtend/file.h> -lxtend SYNOPSIS int xt_read_line_malloc(FILE *stream, char **buff, size_t *buff_size, size_t *len) ARGUMENTS stream: FILE stream from which field is read buff: Character buffer into which field is copied buff_size: Size of the array passed to buff len: Pointer to a variable which will receive the field length DESCRIPTION xt_read_line_malloc() reads a single line of text (up to the next new- line or EOF) from stream, allocating and/or extending the provided buffer if needed. The buff_size argument must be initilized to 0 if buff has not been previously allocated. This will cause an initial allocation to occur. If buff has been previously allocated, the buff_size must accurately reflect the allocated memory size. This will happen naturally when reusing buff in a loop, as shown in the example below. RETURN VALUES Delimiter ending the read: either newline or EOF EXAMPLES FILE *stream; char *buff; size_t buff_len, len; // Reuse buff to minimize malloc() calls. buff will be extended // as needed when longer strings are read. Initialize buff here // rather than above for the most cohesive code. buff_len = 0; while ( ffile_read_line_malloc(stream, buff, &buff_len, &len) != EOF ) { } SEE ALSO xt_dsv_read_field_malloc(3), ffgetc(3) xt_read_line_malloc(3)
NAME | LIBRARY | SYNOPSIS | ARGUMENTS | DESCRIPTION | RETURN VALUES | EXAMPLES | SEE ALSO
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=xt_read_line_malloc&sektion=3&manpath=FreeBSD+Ports+14.3.quarterly>