|
Libft
42 Libft library documentation
|
Include dependency graph for libft.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| int | ft_atoi (const char *str) |
| Converts an ASCII string to an int value. | |
| void | ft_bzero (void *s, size_t n) |
| Sets a memory area to zero bytes. | |
| void * | ft_calloc (size_t count, size_t size) |
| Allocates and zero-initializes an array. | |
| int | ft_isalnum (int c) |
| Checks whether a character is alphanumeric. | |
| int | ft_isalpha (int c) |
| int | ft_isascii (int c) |
| Checks whether a character value is a valid ASCII byte. | |
| int | ft_isdigit (int c) |
| Checks whether a character is a decimal digit. | |
| int | ft_isprint (int c) |
| Checks whether a character is printable in ASCII. | |
| char * | ft_itoa (int n) |
| Converts an integer to a newly allocated decimal string. | |
| void | ft_lstadd_back (t_list **lst, t_list *new) |
| Adds a new element to the end of a linked list. This function takes a pointer to the first element of a linked list and a new element, then adds the new element to the end of the list. If the list is empty, the new element becomes the first element. | |
| void | ft_lstadd_front (t_list **lst, t_list *new) |
| Adds a new element to the front of a linked list. This function takes a pointer to the first element of a linked list and a new element, then adds the new element to the front of the list. The new element becomes the new head of the list. | |
| void | ft_lstclear (t_list **lst, void(*del)(void *)) |
| Clears a linked list. This function takes a pointer to the first element of a linked list and a function pointer to a deletion function, then removes and frees all elements in the list. | |
| void | ft_lstdelone (t_list *lst, void(*del)(void *)) |
| Deletes and frees a single element from a linked list. This function takes an element from a linked list and a function pointer to a deletion function, then removes and frees the element. | |
| void | ft_lstiter (t_list *lst, void(*f)(void *)) |
| Iterates over a linked list and applies a function to each element. This function takes a linked list and a function pointer, then applies the function to the content of each element in the list. | |
| t_list * | ft_lstlast (t_list *lst) |
| Returns the last element of a linked list. This function takes a linked list and returns a pointer to the last element. | |
| t_list * | ft_lstmap (t_list *lst, void *(*f)(void *), void(*del)(void *)) |
| Creates a new linked list with the results of applying a function to each element of the original list. This function takes a linked list and two function pointers, then applies the first function to the content of each element in the list and creates a new list with the results. | |
| t_list * | ft_lstnew (void *content) |
| Creates a new linked-list node. | |
| int | ft_lstsize (t_list *lst) |
| Counts the number of nodes in a linked list. | |
| void * | ft_memchr (const void *s, int c, size_t n) |
| Scans a memory area for a byte value. | |
| int | ft_memcmp (const void *s1, const void *s2, size_t n) |
| Compares two memory areas byte by byte. | |
| void * | ft_memcpy (void *dest, const void *src, size_t n) |
| Copies bytes from source to destination. | |
| void * | ft_memmove (void *dst, const void *src, size_t len) |
| Copies bytes between potentially overlapping memory areas. | |
| void * | ft_memset (void *s, int c, size_t len) |
| Fills a memory area with a byte value. | |
| void | ft_putchar_fd (char c, int fd) |
| Writes one character to a file descriptor. | |
| void | ft_putendl_fd (char *s, int fd) |
| Writes a string followed by a newline to a file descriptor. | |
| void | ft_putnbr_fd (int n, int fd) |
| Writes an integer in decimal format to a file descriptor. | |
| void | ft_putstr_fd (char *s, int fd) |
| Writes a string to a file descriptor. | |
| char ** | ft_split (char const *s, char c) |
| Splits a string into an array of substrings. | |
| char * | ft_strchr (const char *s, int c) |
| Finds the first occurrence of a character in a string. | |
| char * | ft_strdup (const char *s1) |
| Duplicates a C string into newly allocated memory. | |
| void | ft_striteri (char *s, void(*f)(unsigned int, char *)) |
| Applies a callback to each character of a string in place. | |
| char * | ft_strjoin (char const *s1, char const *s2) |
| Concatenates two strings into a newly allocated string. | |
| size_t | ft_strlcat (char *dest, const char *src, size_t len) |
| Appends a string to a bounded destination buffer. | |
| size_t | ft_strlcpy (char *dest, const char *src, size_t size) |
| Copies a string into a bounded destination buffer. | |
| size_t | ft_strlen (const char *str) |
| Returns the length of a null-terminated string. | |
| char * | ft_strmapi (char const *s, char(*f)(unsigned int, char)) |
| Maps a function over a string into a new allocated string. | |
| int | ft_strncmp (const char *s1, const char *s2, size_t n) |
| Compares two strings up to a maximum number of characters. | |
| char * | ft_strnstr (const char *haystack, const char *needle, size_t len) |
| Finds a substring within a bounded string region. | |
| char * | ft_strrchr (const char *s, int c) |
| Finds the last occurrence of a character in a string. | |
| char * | ft_strtrim (char const *s1, char const *set) |
| Trims leading and trailing characters from a set. | |
| char * | ft_substr (char const *s, unsigned int start, size_t len) |
| Extracts a substring from a string. | |
| int | ft_tolower (int c) |
| Converts an uppercase ASCII letter to lowercase. | |
| int | ft_toupper (int c) |
| Converts a lowercase ASCII letter to uppercase. | |
| int ft_atoi | ( | const char * | str | ) |
Converts an ASCII string to an int value.
Skips leading whitespace, parses an optional sign, then accumulates consecutive decimal digits.
| str | Input C string. |
Definition at line 22 of file ft_atoi.c.
| void ft_bzero | ( | void * | void_ptr, |
| size_t | n | ||
| ) |
Sets a memory area to zero bytes.
| void_ptr | Pointer to the memory block. |
| n | Number of bytes to zero. |
Definition at line 21 of file ft_bzero.c.
References ft_memset().
Here is the call graph for this function:| void * ft_calloc | ( | size_t | nmemb, |
| size_t | size | ||
| ) |
Allocates and zero-initializes an array.
Allocates memory for nmemb elements of size bytes each and sets all allocated bytes to zero. Returns NULL on overflow or allocation failure.
| nmemb | Number of elements. |
| size | Size of each element in bytes. |
Definition at line 26 of file ft_calloc.c.
References ft_memset().
Here is the call graph for this function:| int ft_isalnum | ( | int | c | ) |
Checks whether a character is alphanumeric.
| c | Character value to test. |
c is a letter or a digit, 0 otherwise. Definition at line 19 of file ft_isalnum.c.
| int ft_isalpha | ( | int | c | ) |
| int ft_isascii | ( | int | c | ) |
Checks whether a character value is a valid ASCII byte.
| c | Character value to test. |
c is in [0, 127], 0 otherwise. Definition at line 19 of file ft_isascii.c.
| int ft_isdigit | ( | int | c | ) |
Checks whether a character is a decimal digit.
| c | Character value to test. |
c is in ['0', '9'], 0 otherwise. Definition at line 19 of file ft_isdigit.c.
| int ft_isprint | ( | int | c | ) |
Checks whether a character is printable in ASCII.
| c | Character value to test. |
c is in [32, 126], 0 otherwise. Definition at line 19 of file ft_isprint.c.
| char * ft_itoa | ( | int | n | ) |
Converts an integer to a newly allocated decimal string.
| n | Integer value to convert. |
Definition at line 23 of file ft_itoa.c.
References ft_num_len().
Here is the call graph for this function:Adds a new element to the end of a linked list. This function takes a pointer to the first element of a linked list and a new element, then adds the new element to the end of the list. If the list is empty, the new element becomes the first element.
| lst | A pointer to the pointer to the first element of the list. |
| new | The new element to add to the end of the list. |
Definition at line 25 of file ft_lstadd_back.c.
References ft_lstlast(), and s_list::next.
Referenced by ft_lstmap().
Here is the call graph for this function:
Here is the caller graph for this function:Adds a new element to the front of a linked list. This function takes a pointer to the first element of a linked list and a new element, then adds the new element to the front of the list. The new element becomes the new head of the list.
| lst | A pointer to the pointer to the first element of the list. |
| new | The new element to add to the front of the list. |
Definition at line 24 of file ft_lstadd_front.c.
| void ft_lstclear | ( | t_list ** | lst, |
| void(*)(void *) | del | ||
| ) |
Clears a linked list. This function takes a pointer to the first element of a linked list and a function pointer to a deletion function, then removes and frees all elements in the list.
| lst | A pointer to the pointer to the first element of the list. |
| del | A function pointer to the deletion function. |
Definition at line 25 of file ft_lstclear.c.
References ft_lstdelone(), and s_list::next.
Referenced by ft_lstmap().
Here is the call graph for this function:
Here is the caller graph for this function:| void ft_lstdelone | ( | t_list * | lst, |
| void(*)(void *) | del | ||
| ) |
Deletes and frees a single element from a linked list. This function takes an element from a linked list and a function pointer to a deletion function, then removes and frees the element.
| lst | The element to delete and free. |
| del | A function pointer to the deletion function. |
Definition at line 24 of file ft_lstdelone.c.
References s_list::content.
Referenced by ft_lstclear().
Here is the caller graph for this function:| void ft_lstiter | ( | t_list * | lst, |
| void(*)(void *) | f | ||
| ) |
Iterates over a linked list and applies a function to each element. This function takes a linked list and a function pointer, then applies the function to the content of each element in the list.
| lst | The linked list to iterate over. |
| f | The function to apply to each element. |
Definition at line 23 of file ft_lstiter.c.
References s_list::content, and s_list::next.
Returns the last element of a linked list. This function takes a linked list and returns a pointer to the last element.
| lst | The linked list to search. |
Definition at line 23 of file ft_lstlast.c.
References s_list::next.
Referenced by ft_lstadd_back().
Here is the caller graph for this function:Creates a new linked list with the results of applying a function to each element of the original list. This function takes a linked list and two function pointers, then applies the first function to the content of each element in the list and creates a new list with the results.
| lst | The linked list to iterate over. |
| f | The function to apply to each element. |
| del | The function to delete each element. |
Definition at line 26 of file ft_lstmap.c.
References s_list::content, ft_lstadd_back(), ft_lstclear(), ft_lstnew(), and s_list::next.
Here is the call graph for this function:| t_list * ft_lstnew | ( | void * | content | ) |
Creates a new linked-list node.
The node is initialized with content and its next pointer is set to NULL.
| content | Pointer stored in the node. |
Definition at line 24 of file ft_lstnew.c.
References s_list::content, and s_list::next.
Referenced by ft_lstmap().
Here is the caller graph for this function:| int ft_lstsize | ( | t_list * | lst | ) |
Counts the number of nodes in a linked list.
| lst | Head of the list. |
Definition at line 21 of file ft_lstsize.c.
References s_list::next.
| void * ft_memchr | ( | const void * | s, |
| int | c, | ||
| size_t | n | ||
| ) |
Scans a memory area for a byte value.
| s | Pointer to the memory area. |
| c | Byte value to search for. |
| n | Number of bytes to inspect. |
Definition at line 23 of file ft_memchr.c.
| int ft_memcmp | ( | const void * | s1, |
| const void * | s2, | ||
| size_t | n | ||
| ) |
Compares two memory areas byte by byte.
| s1 | First memory area. |
| s2 | Second memory area. |
| n | Number of bytes to compare. |
Definition at line 23 of file ft_memcmp.c.
| void * ft_memcpy | ( | void * | dest, |
| const void * | src, | ||
| size_t | n | ||
| ) |
Copies bytes from source to destination.
Behavior is undefined for overlapping regions; use ft_memmove for overlap.
| dest | Destination memory area. |
| src | Source memory area. |
| n | Number of bytes to copy. |
dest pointer, or NULL when both pointers are NULL. Definition at line 25 of file ft_memcpy.c.
Referenced by ft_strdup(), and ft_strjoin().
Here is the caller graph for this function:| void * ft_memmove | ( | void * | dst, |
| const void * | src, | ||
| size_t | len | ||
| ) |
Copies bytes between potentially overlapping memory areas.
| dst | Destination memory area. |
| src | Source memory area. |
| len | Number of bytes to copy. |
dst pointer, or NULL when both pointers are NULL. Definition at line 23 of file ft_memmove.c.
| void * ft_memset | ( | void * | s, |
| int | c, | ||
| size_t | len | ||
| ) |
Fills a memory area with a byte value.
| s | Pointer to the memory area. |
| c | Byte value used for filling. |
| len | Number of bytes to set. |
s pointer. Definition at line 23 of file ft_memset.c.
Referenced by ft_bzero(), and ft_calloc().
Here is the caller graph for this function:| void ft_putchar_fd | ( | char | c, |
| int | fd | ||
| ) |
Writes one character to a file descriptor.
| c | Character to write. |
| fd | Destination file descriptor. |
Definition at line 21 of file ft_putchar_fd.c.
Referenced by ft_putnbr_fd().
Here is the caller graph for this function:| void ft_putendl_fd | ( | char * | s, |
| int | fd | ||
| ) |
Writes a string followed by a newline to a file descriptor.
Does nothing when s is NULL.
| s | String to write. |
| fd | Destination file descriptor. |
Definition at line 23 of file ft_putendl_fd.c.
References ft_putstr_fd().
Here is the call graph for this function:| void ft_putnbr_fd | ( | int | n, |
| int | fd | ||
| ) |
Writes an integer in decimal format to a file descriptor.
Handles negative values and the full int range.
| n | Value to write. |
| fd | Destination file descriptor. |
Definition at line 23 of file ft_putnbr_fd.c.
References ft_putchar_fd(), and ft_putnbr_fd().
Referenced by ft_putnbr_fd().
Here is the call graph for this function:
Here is the caller graph for this function:| void ft_putstr_fd | ( | char * | s, |
| int | fd | ||
| ) |
Writes a string to a file descriptor.
Does nothing when s is NULL.
| s | String to write. |
| fd | Destination file descriptor. |
Definition at line 23 of file ft_putstr_fd.c.
References ft_strlen().
Referenced by ft_putendl_fd().
Here is the call graph for this function:
Here is the caller graph for this function:| char ** ft_split | ( | char const * | s, |
| char | c | ||
| ) |
Splits a string into an array of substrings.
Uses the delimiter c to separate words. The returned array is NULL-terminated.
| s | Input string. |
| c | Delimiter character. |
Definition at line 30 of file ft_split.c.
References ft_count_words(), and ft_fill_split().
Here is the call graph for this function:| char * ft_strchr | ( | const char * | s, |
| int | c | ||
| ) |
Finds the first occurrence of a character in a string.
The terminating '\0' is considered part of the string.
| s | Input string. |
| c | Character to search for. |
Definition at line 24 of file ft_strchr.c.
Referenced by ft_strtrim().
Here is the caller graph for this function:| char * ft_strdup | ( | const char * | s | ) |
Duplicates a C string into newly allocated memory.
| s | Source string. |
Definition at line 21 of file ft_strdup.c.
References ft_memcpy(), and ft_strlen().
Referenced by ft_substr().
Here is the call graph for this function:
Here is the caller graph for this function:| void ft_striteri | ( | char * | s, |
| void(*)(unsigned int, char *) | f | ||
| ) |
Applies a callback to each character of a string in place.
The callback receives the character index and a pointer to the character.
| s | String to modify. |
| f | Callback applied to each character. |
Definition at line 21 of file ft_striteri.c.
| char * ft_strjoin | ( | char const * | s1, |
| char const * | s2 | ||
| ) |
Concatenates two strings into a newly allocated string.
| s1 | First input string. |
| s2 | Second input string. |
Definition at line 22 of file ft_strjoin.c.
References ft_memcpy(), and ft_strlen().
Here is the call graph for this function:| size_t ft_strlcat | ( | char * | dest, |
| const char * | src, | ||
| size_t | size | ||
| ) |
Appends a string to a bounded destination buffer.
| dest | Destination buffer. |
| src | Source string. |
| size | Full size of dest buffer. |
Definition at line 23 of file ft_strlcat.c.
References ft_strlen().
Here is the call graph for this function:| size_t ft_strlcpy | ( | char * | dest, |
| const char * | src, | ||
| size_t | size | ||
| ) |
Copies a string into a bounded destination buffer.
| dest | Destination buffer. |
| src | Source string. |
| size | Size of dest buffer. |
src. Definition at line 23 of file ft_strlcpy.c.
References ft_strlen().
Referenced by ft_substr().
Here is the call graph for this function:
Here is the caller graph for this function:| size_t ft_strlen | ( | const char * | str | ) |
Returns the length of a null-terminated string.
| str | Input string. |
Definition at line 21 of file ft_strlen.c.
Referenced by ft_putstr_fd(), ft_strdup(), ft_strjoin(), ft_strlcat(), ft_strlcpy(), ft_strmapi(), ft_strrchr(), ft_strtrim(), and ft_substr().
Here is the caller graph for this function:| char * ft_strmapi | ( | char const * | s, |
| char(*)(unsigned int, char) | f | ||
| ) |
Maps a function over a string into a new allocated string.
| s | Input string. |
| f | Mapping callback receiving index and character. |
Definition at line 22 of file ft_strmapi.c.
References ft_strlen().
Here is the call graph for this function:| int ft_strncmp | ( | const char * | s1, |
| const char * | s2, | ||
| size_t | n | ||
| ) |
Compares two strings up to a maximum number of characters.
| s1 | First string. |
| s2 | Second string. |
| n | Maximum number of characters to compare. |
Definition at line 23 of file ft_strncmp.c.
| char * ft_strnstr | ( | const char * | haystack, |
| const char * | needle, | ||
| size_t | len | ||
| ) |
Finds a substring within a bounded string region.
Searches needle in haystack but not beyond len bytes.
| haystack | String to search in. |
| needle | Substring to search for. |
| len | Maximum number of bytes to inspect in haystack. |
Definition at line 25 of file ft_strnstr.c.
| char * ft_strrchr | ( | const char * | s, |
| int | c | ||
| ) |
Finds the last occurrence of a character in a string.
| s | Input string. |
| c | Character to search for. |
Definition at line 22 of file ft_strrchr.c.
References ft_strlen().
Here is the call graph for this function:| char * ft_strtrim | ( | char const * | s1, |
| char const * | set | ||
| ) |
Trims leading and trailing characters from a set.
| s1 | Source string. |
| set | Set of characters to trim. |
Definition at line 22 of file ft_strtrim.c.
References ft_strchr(), ft_strlen(), and ft_substr().
Here is the call graph for this function:| char * ft_substr | ( | char const * | s, |
| unsigned int | start, | ||
| size_t | len | ||
| ) |
Extracts a substring from a string.
| s | Source string. |
| start | Start index in s. |
| len | Maximum substring length. |
Definition at line 23 of file ft_substr.c.
References ft_strdup(), ft_strlcpy(), and ft_strlen().
Referenced by ft_fill_split(), and ft_strtrim().
Here is the call graph for this function:
Here is the caller graph for this function:| int ft_tolower | ( | int | c | ) |
Converts an uppercase ASCII letter to lowercase.
| c | Character value. |
Definition at line 19 of file ft_tolower.c.
| int ft_toupper | ( | int | c | ) |
Converts a lowercase ASCII letter to uppercase.
| c | Character value. |
Definition at line 19 of file ft_toupper.c.