Libft
Custom implementation of core libc functions with additional utility helpers.
Loading...
Searching...
No Matches
Get Next Chunk

Chunk-by-chunk file reading (customizable separator). More...

Functions

t_buffget_next_chunk (int fd, char separator)
 Reads the next chunk from a file descriptor until separator is found.
void get_next_chunk_free (void)
 Frees all internal stashes used by get_next_chunk.

Detailed Description

Chunk-by-chunk file reading (customizable separator).

Functions to read chunks from file descriptors with persistent state.

Function Documentation

◆ get_next_chunk()

t_buff * get_next_chunk ( int fd,
char separator )

Reads the next chunk from a file descriptor until separator is found.

Returns the chunk even if EOF is reached before separator is found. Returns NULL only when called after EOF has already been reached.

Note
Caller owns the returned t_buff and must free both the struct and its internal data (use buff_free then free).
Parameters
fdFile descriptor to read from.
separatorCharacter to stop reading at (included in returned chunk).
Returns
Pointer to a newly allocated t_buff (owned), or NULL on error/EOF.
Here is the call graph for this function:

◆ get_next_chunk_free()

void get_next_chunk_free ( void )

Frees all internal stashes used by get_next_chunk.

Call this to clean up when done reading from all file descriptors.

Here is the call graph for this function: