-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Ivany Pinheiro edited this page Dec 9, 2024
·
4 revisions
This project serves as a learning exercise in handling file descriptors and efficiently managing buffer operations in C. The goal of the project is to implement a function, get_next_line
, which reads a single line from a file descriptor and handles subsequent calls effectively, even with multiple file descriptors.
/gnl │ ├── /inc │ └── get_next_line.h │ ├── /src │ ├── get_next_line.c │ └── get_next_line_utils.c │ ├── /test │ ├── test.c │ ├── test1.txt │ └── test2.txt │ ├── Makefile └── gui_load.sh
/inc
: Contains the header file defining the function prototypes and macros for the project.
/src
: Contains the source files for the main implementation of the get_next_line
function and its helper utilities.
/test
: Contains test cases and input files to verify the functionality of the implementation.
General | Utilities |
---|---|
get_next_line |
get_next_line_utils |
- The
get_next_line
function is the core of this project. It reads a single line from a given file descriptor, returning it as a dynamically allocated string. This function is designed to handle buffers, partial reads, and newlines efficiently. It ensures that subsequent calls continue from where the last read ended, supporting continuous reading from multiple file descriptors simultaneously.
- The utility functions support the operation of
get_next_line
. These functions perform tasks such as managing buffers, handling memory allocation for dynamic strings, and splitting strings at newline characters. They ensure thatget_next_line
operates efficiently without memory leaks or errors.