/Libft

Primary LanguageC

Libft

mandatory passed, bonuses not tested

Description Param. #1 Param. #2 Param. #3 Return Value External functs (except for inside functions)
int ft_atoi(const char *nptr); Converts a string to an integer The string to be converted to int The converted value
void ft_bzero(void *s, size_t n); Erases the data in the "n" bytes of the memory starting at the location pointed by "s" writing zeroes The string on which to operate The number of bytes None
void *ft_calloc(size_t nmemb, size_t size); Allocates enough space for nmemb objects that are size bytes of memory each, and returns a pointer to the allocated memory. The allocated memory is filled with bytes of value zero Number of elements to be allocated Size of elements A pointer to the allocated memory, or NULL if the request fails malloc
int ft_isalnum(int c); Checks for an alphanumeric character; it is equivalent to (ft_isalpha or ft_isdigit) The character to test 0 if the character tests false and 1 if the character tests true
int ft_isalpha(int c); Checks for a alpabetic character, it is equivalent to (ft_isupper(c) or ft_islower(c)) The character to test 0 if the character tests false and 1 if the character tests true
int ft_isascii(int c); Checks for an ASCII character, which is any character between 0 and octal 0177 inclusive The character to test 0 if the character tests false and 1 if the character tests true
int ft_isdigit(int c); Checks for a digit (0 through 9) The character to test 0 if the character tests false and 1 if the character tests true
int ft_isprint(int c); Checks for any printable character including space The character to test 0 if the character tests false and 1 if the character tests true
char *ft_itoa(int n); Allocates (with malloc) and returns a string representing the integer received as an argument. Negative numbers must be handled The integer to convert The string representing the integer. NULL if the allocation fails. malloc
void ft_lstadd_back(t_list **lst, t_list *new); Adds the node ’new’ at the end of the list. In case of the new is empty, it still returns the last list of lst The address of a pointer to the first link of a list. The address of a pointer to the node to be added to the list. None
void ft_lstadd_front(t_list **lst, t_list *new); Adds the node ’new’ at the beginning of the list. The address of a pointer to the first link of a list. The address of a pointer to the node to be added to the list. None
void ft_lstclear(t_list **lst, void (*del)(void*)); Deletes and frees the given node and every successor of that node, using the function ’del’ and free(3). Finally, the pointer to the list must be set to NULL. The address of a pointer to a node. The address of the function used to delete the content of the node. None free
void ft_lstdelone(t_list *lst, void (*del)(void*)); Takes as a parameter a node and frees the memory of the node’s content using the function ’del’ given as a parameter and free the node. The memory of ’next’ must not be freed. The node to free. The address of the function used to delete the content. None free
void ft_lstiter(t_list *lst, void (*f)(void *)); Iterates the list ’lst’ and applies the function ’f’ on the content of each node. The address of a pointer to a node. The address of the function used to iterate on the list. None
t_list *ft_lstlast(t_list *lst); Returns the last node of the list. The beginning of the list. Last node of the list
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)); Iterates the list ’lst’ and applies the function ’f’ on the content of each node. Creates a new list resulting of the successive applications of the function ’f’. The ’del’ function is used to delete the content of a node if needed. The address of a pointer to a node. The address of the function used to iterate on the list. The address of the function used to delete the content of a node if needed. The new list. NULL if the allocation fails. malloc, free
t_list *ft_lstnew(void *content); Allocates (with malloc(3)) and returns a new node. The member variable ’content’ is initialized with the value of the parameter ’content’. The variable ’next’ is initialized to NULL. The content to create the node with The new node malloc
int ft_lstsize(t_list *lst); Counts the number of nodes in a list. The beginning of the list. The length of the list
void *ft_memchr(const void *s, int c, size_t n); Scans the initial n bytes of s for the first instance of c Memory area s A character to search The number of bytes A pointer to the matching byte or NULL if the character does not occur in the given memory area
int ft_memcmp(const void *s1, const void *s2, size_t n); Compares byte string s1 against byte string s2 Memory area s1 Memory area s2 The number of bytes < 0 if s1 is less than s2, > 0 if s1 is graeter than s2, = 0 if s1 is equal to s2
void *ft_memcpy(void *dest, const void *src, size_t n); Copies n bytes from memory area src to memory of dest. The memory areas must not overlap. Use ft_memmove if the memory areas do overlap. Memory area dest Memory area src The number of bytes A pointer to the memory area dest
void *ft_memmove(void *dest, const void *src, size_t n); Copies n bytes from the memory area of src to dest. Memories may overlap. First, the bytes in src are copied into a temporary array and then to dest. Memory area dest Memory area src The number of bytes A pointer to the memory area dest
void *ft_memset(void *s, int c, size_t n); Fill the memory of "s"with "n" bytes of "c" The string on which to operate Value c (converted to an unsigned char) The number of bytes A pointer to the memory area s
void ft_putchar_fd(char c, int fd); Outputs the character ’c’ to the given file descriptor. The character to output. The file descriptor on which to write None write
void ft_putendl_fd(char *s, int fd); Outputs the string ’s’ to the given file descriptor followed by a newline. The string to output. The file descriptor on which to write None write
void ft_putnbr_fd(int n, int fd); Outputs the integer ’n’ to the given file descriptor. The integer to output. The file descriptor on which to write None write
void ft_putstr_fd(char *s, int fd); Outputs the string ’s’ to the given file descriptor. The string to output. The file descriptor on which to write. None write
char **ft_split(char const *s, char c); Allocates (with malloc(3)) and returns an array of strings obtained by splitting ’s’ using the character ’c’ as a delimiter. The array must end with a NULL pointer. The string to be split. The delimiter character. The array of new strings resulting from the split. NULL if the allocation fails. malloc, free
char *ft_strchr(const char *s, int c); Locates the first occurrence of 'c' in the string pointed to by 's'. The terminating null character is considered to be part of the string, therefore if 'c' is '\0', locates the terminating '\0' Pointer to string Character to be located A pointer to the first occurrence of the character c in the string or NULL if the character is not found
char *ft_strdup(const char *s); Duplicate string s1. Memory for the new string is obtained with malloc, and can be freed with free The string to duplicate A pointer to the duplicated string. NULL if insufficient memory was available malloc
void ft_striteri(char *s, void (*f)(unsigned int, char*)); Applies the function ’f’ on each character of the string passed as argument, passing its index as first argument. Each character is passed by address to ’f’ to be modified if necessary. The string on which to iterate. The function to apply to each character. None
char *ft_strjoin(char const *s1, char const *s2); Allocates (with malloc(3)) and returns a new string, which is the result of the concatenation of ’s1’ and ’s2’. The prefix string. The suffix string The new string. NULL if the allocation fails. malloc
size_t ft_strlcat(char *dst, const char *src, size_t size); Concatenate the string src to the end of dst. It will concatenate at most size - strlen(dst) - 1 bytes, NUL-terminating the result Destination array String to be appended to dst Maximum number of characters to be appended The initial length of dst plus the length of src
size_t ft_strlcpy(char *dst, const char *src, size_t size); Copies up to size - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result Destination array String to be copied Number of characters to be copied from src Total length of the string to create (length of src)
int ft_strlen(const char *s); Calculates the length of the string pointed to by s, excluding the terminating null byte ('\0') The string to calculate Number of characters in the string pointed to by s
char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); Applies the function ’f’ to each character of the string ’s’, and passing its index as first argument to create a new string (with malloc(3)) resulting from successive applications of ’f’ The string on which to iterate. The function to apply to each character The string created from the successive applications of ’f’. Returns NULL if the allocation fails. malloc
int ft_strncmp(const char *s1, const char *s2, size_t n); Compares the first (at most) n bytes of the two strings s1 and s2. It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2. The string 1 to compare The string 2 to compare An integer less than, equal to, or greater than zero if s1 (or the first n bytes thereof) is found, respectively, to be less than, to match, or be greater than s2
char *ft_strnstr(const char *big, const char *little, size_t len); Locate substring, where not more than 'len' characters are searched. Finds the first occurrence of the substring 'little' in the string 'big'. The terminating null bytes ('\0') are not compared. Big string to be scanned The little substring to be searched in 'big' string The maximum amount of characters to be searched A pointer to the first character of the first occurrence of 'little' is returned. NULL if the substring is not found. If 'little' is an empty string, 'big' is returned
char *ft_strrchr(const char *s, int c); Locates the last occurrence of 'c' in the string pointed to by 's'. The terminating null character is considered to be part of the string, therefore if 'c' is '\0', locates the terminating '\0' Pointer to string Character to be located A pointer to the last occurrence of the character c in the string or NULL if the character is not found
char *ft_strtrim(char const *s1, char const *set); Allocates (with malloc) and returns a copy of the string given as argument without the characters specified in the set argument at the beginning and the end of the string The string to be trimmed The reference set of character to trim The trimmed string. NULL if the allocation fails malloc
char *ft_substr(char const *s, unsigned int start, size_t len); Allocates (with malloc) and returns a substring from the string given in argument. The substring begins at index 'start' and is of maximum size 'len' The string from which create the substring The start index of the substring in the string The maximum length of the substring The substring. NULL if the allocation fails malloc
int ft_tolower(int c); If the character passed as an argument is an uppercase, convert to lower The character to convert If c is a uppercase letter, returns its lowercase equivalent. Otherwise, it returns c.
int ft_toupper(int c); If the character passed as an argument is a lowercase, convert to upper The character to convert If c is a lowercase letter, returns its uppercase equivalent. Otherwise, it returns c.