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


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

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