|
Libft
Custom implementation of core libc functions with additional utility helpers.
|
Dynamic growable buffer utilities. More...
Functions | |
| bool | buff_init (t_buff *b, size_t initial_cap) |
| Initializes a buffer with the specified initial capacity. | |
| bool | buff_adjust (t_buff *buff) |
| Shrinks buffer capacity to match its current length. | |
| void | buff_free (t_buff *b) |
| Frees the buffer's internal data. | |
| int | buff_get_index (t_buff *buff, char c) |
| Finds the index of a character in the buffer. | |
| bool | buff_prepend (t_buff *b, const char *str, long n) |
| Prepends a string to the beginning of the buffer. | |
| bool | buff_insert (t_buff *b, size_t index, const char *str, long n) |
| Inserts a string at a specific index in the buffer. | |
| bool | buff_append (t_buff *b, const char *str, long n) |
| Appends a string to the end of the buffer. | |
| t_buff * | buff_dup_n (const t_buff *src, size_t n) |
| Duplicates up to n bytes of a buffer into a new buffer. | |
| void | buff_rm_part (t_buff *buff, size_t i_start, ssize_t len) |
| Removes a portion of the buffer starting at i_start. | |
| bool | buff_append_format (t_buff *buff, const char *fstring,...) |
| Appends formatted string to buffer using variadic arguments. | |
| bool | buff_append_vformat (t_buff *buff, const char *fstring, va_list args) |
| Appends formatted string to buffer using va_list. | |
| int | buff_read_until (t_buff *buff, int fd, char c) |
| Reads from a file descriptor until a specific character is found. | |
| bool | buff_read_all (t_buff *buff, int fd) |
| Reads all available data from a file descriptor into buffer. | |
Dynamic growable buffer utilities.
Functions to initialize, grow, shrink and manipulate dynamic buffers.
| bool buff_adjust | ( | t_buff * | buff | ) |
Shrinks buffer capacity to match its current length.
| buff | Pointer to an initialized buffer (borrowed). |


| bool buff_append | ( | t_buff * | b, |
| const char * | str, | ||
| long | n ) |
Appends a string to the end of the buffer.
Buffer is automatically grown if necessary.
| b | Pointer to an initialized buffer (borrowed). |
| str | String to append (borrowed, not modified). |
| n | Number of bytes to append, or -1 to use strlen(str). |


| bool buff_append_format | ( | t_buff * | buff, |
| const char * | fstring, | ||
| ... ) |
Appends formatted string to buffer using variadic arguments.
Supports printf formats: %c %s %d %i %u %x %X %p %%.
Supports printf-like flags: - 0 . # + and width.
| buff | Pointer to an initialized buffer (borrowed). |
| fstring | Format string (borrowed). |
| ... | Variadic arguments for format specifiers. |

| bool buff_append_vformat | ( | t_buff * | buff, |
| const char * | fstring, | ||
| va_list | args ) |
Appends formatted string to buffer using va_list.
| buff | Pointer to an initialized buffer (borrowed). |
| fstring | Format string (borrowed). |
| args | Variable argument list. |


Duplicates up to n bytes of a buffer into a new buffer.
| src | Source buffer to duplicate (borrowed). |
| n | Maximum number of bytes to copy. |


| void buff_free | ( | t_buff * | b | ) |
Frees the buffer's internal data.
Sets buff->data to NULL after freeing.
| b | Pointer to the buffer (borrowed). |

| int buff_get_index | ( | t_buff * | buff, |
| char | c ) |
Finds the index of a character in the buffer.
| buff | Pointer to an initialized buffer (borrowed). |
| c | Character to find. |

| bool buff_init | ( | t_buff * | b, |
| size_t | initial_cap ) |
Initializes a buffer with the specified initial capacity.
| b | Pointer to the buffer structure to initialize (uninitialized). |
| initial_cap | Initial capacity of the buffer. |

| bool buff_insert | ( | t_buff * | b, |
| size_t | index, | ||
| const char * | str, | ||
| long | n ) |
Inserts a string at a specific index in the buffer.
Buffer is automatically grown if necessary.
| b | Pointer to an initialized buffer (borrowed). |
| index | Position at which to insert the string. |
| str | String to insert (borrowed, not modified). |
| n | Number of bytes to insert, or -1 to use strlen(str). |


| bool buff_prepend | ( | t_buff * | b, |
| const char * | str, | ||
| long | n ) |
Prepends a string to the beginning of the buffer.
Buffer is automatically grown if necessary.
| b | Pointer to an initialized buffer (borrowed). |
| str | String to prepend (borrowed, not modified). |
| n | Number of bytes to prepend, or -1 to use strlen(str). |


| bool buff_read_all | ( | t_buff * | buff, |
| int | fd ) |
Reads all available data from a file descriptor into buffer.
| buff | Pointer to an initialized buffer (borrowed). |
| fd | File descriptor to read from. |

| int buff_read_until | ( | t_buff * | buff, |
| int | fd, | ||
| char | c ) |
Reads from a file descriptor until a specific character is found.
| buff | Pointer to an initialized buffer (borrowed). |
| fd | File descriptor to read from. |
| c | Character to search for. |


| void buff_rm_part | ( | t_buff * | buff, |
| size_t | i_start, | ||
| ssize_t | len ) |
Removes a portion of the buffer starting at i_start.
| buff | Pointer to an initialized buffer (borrowed). |
| i_start | Starting index for removal. |
| len | Number of bytes to remove, or negative to remove until end. |

