Skip to content
Ivany Pinheiro edited this page Dec 9, 2024 · 4 revisions

Documentation

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.

Directory Tree

/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.

Logical Groups

General Utilities
get_next_line get_next_line_utils

General Functions

  • 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.

Utility Functions

  • 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 that get_next_line operates efficiently without memory leaks or errors.

Next ➡️

Clone this wiki locally