|
Libft
Custom implementation of core libc functions with additional utility helpers.
|


Go to the source code of this file.
Functions | |
| size_t | buff_get_required_cap (size_t current_cap, size_t target_len) |
| Calculates the required capacity to accommodate a target length. | |
| ssize_t | buff_read_n_bytes (t_buff *buff, int fd, size_t n) |
| Reads up to n bytes from a file descriptor into a buffer. | |
| size_t buff_get_required_cap | ( | size_t | current_cap, |
| size_t | target_len | ||
| ) |
Calculates the required capacity to accommodate a target length.
Uses exponential growth strategy (doubles capacity) to amortize multiple growth operations to O(1) on average.
| current_cap | Current capacity of the buffer. |
| target_len | Target length to accommodate. |

| ssize_t buff_read_n_bytes | ( | t_buff * | buff, |
| int | fd, | ||
| size_t | n | ||
| ) |
Reads up to n bytes from a file descriptor into a buffer.
Reads directly at the end of buff->data and increases buff->len by the number of bytes read. Reading stops after n bytes, EOF, or a read error.
| buff | Pointer to an initialized buffer (borrowed). |
| fd | File descriptor to read from. |
| n | Maximum number of bytes to read. |
