School 42 project - Libft.
void *ft_memset(void *str, int c, size_t n)
Sets the first n bytes of the block of memory pointed by str to the specified value (interpreted as an unsigned char).
Returns a pointer to str.
void ft_bzero(void *str, size_t n)
Sets the first n bytes of the block of memory pointed by str to zero.
None.
void *ft_memcpy(void *dest, const void *src, size_t n)
Copies n bytes from memory area src to memory area dest. The memory areas must not overlap. Use ft_memmove if the memory areas do overlap.
Returns a pointer to dest.
void *ft_memccpy(void *dest, const void *src, int c, size_t n)
Copies no more than n bytes from memory area src to memory area dest, stopping when the character c is found. If the memory areas overlap, the results are undefined.
Returns a pointer to the next character in dest after c, or NULL if c was not found in the first n characters of src.
void *ft_memmove(void *dest, const void *src, size_t n)
Copies n bytes from memory area src to memory area dest. The memory areas may overlap.
Returns a pointer to dest.
void *ft_memchr(const void *str, int c, size_t n)
Scans the initial n bytes of the memory area pointed to by str for the first instance of c. Both c and the bytes of the memory area pointed to by str are interpreted as unsigned char.
Returns a pointer to the matching byte or NULL if the character does not occur in the given memory area.
int ft_memcmp(const void *buf1, const void *buf2, size_t n)
Compares the first n bytes (each interpreted as unsigned char) of the memory areas buf1 and buf2.
Returns an integer less than, equal to, or greater than zero if the first n bytes of buf1 is found, respectively, to be less than, to match, or be greater than the first n bytes of buf2. For a nonzero return value, the sign is determined by the sign of the difference between the first pair of bytes (interpreted as unsigned char) that differ in buf1 and buf2.
size_t ft_strlen(const char *str)
Calculates the length of the string str, excluding the terminating null byte.
Returns the number of bytes in the string str.
Returns a pointer to a new string which is a duplicate of the string s. Memory for the new string is obtained with malloc, and can be freed with free.
Returns a pointer to the duplicated string, or NULL if insufficient memory was available.
char *ft_strcpy(char *str1, const char *str2)
[description]
[return_value]
char *ft_strncpy(char *dest, const char *src, size_t n)
[description]
[return_value]
char *ft_strcat(char *s1, const char *s2)
[description]
[return_value]
char *ft_strncat(char *s1, const char *s2, size_t n)
[description]
[return_value]
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
[description]
[return_value]
char *ft_strchr(const char *s, int c)
[description]
[return_value]
char *ft_strrchr(const char *s, int c)
[description]
[return_value]
char *ft_strstr(const char *s1, const char *s2)
[description]
[return_value]
char *ft_strnstr(const char *s1, const char *s2, size_t len)
[description]
[return_value]
int ft_strcmp(const char *str1, const char *str2)
[description]
[return_value]
int ft_strncmp(const char *s1, const char *s2, size_t n)
[description]
[return_value]
int ft_atoi(const char *str)
[description]
[return_value]
int ft_isalpha(int c)
[description]
[return_value]
int ft_isdigit(int c)
[description]
[return_value]
int ft_isalnum(int c)
[description]
[return_value]
int ft_isascii(int c)
[description]
[return_value]
int ft_isprint(int c)
[description]
[return_value]
int ft_toupper(int c)
[description]
[return_value]
int ft_tolower(int c)
[description]
[return_value]
void * ft_memalloc(size_t size)
Allocates with malloc and returns a "fresh" memory area. The memory allocated is initialized to 0. If the allocation fails, the function returns NULL.
Returns the allocated memory area.
void ft_memdel(void **ap)
Takes as a parameter the address of a memory area that needs to be freed with free, then puts the pointer to NULL.
None.
char * ft_strnew(size_t size)
Allocates with malloc and returns a "fresh" string ending with '\0'. Each character of the string is initialized at '\0'. If the allocation fails the function returns NULL.
Returns the string allocated and initialized to 0.
void ft_strdel(char **as)
Takes as a parameter the address of a string that need to be freed with free, then sets its pointer to NULL.
None.
void ft_strclr(char *s)
Sets every character of the string to the value '\0'.
None.
void ft_striter(char *s, void (*f)(char *))
Applies the function f to each character of the string passed as argument. Each character is passed by address to f to be modified if necessary.
None.
void ft_striteri(char *s, void (*f)(unsigned int, char *))
Applies the function f to each character of the string passed as argument, and passing its index as first argument. Each character is passed by address to f to be modified if necessary.
None.
char * ft_strmap(char const *s, char (*f)(char))
Applies the function f to each character of the string given as argument to create a "fresh" new string with malloc resulting from the successive applications of f.
Returns the "fresh" string created from the successive applications of f.
char * ft_strmapi(char const *s, char (*f)(unsigned int, char))
Applies the function f to each character of the string passed as argument by giving its index as first argument to create a "fresh" new string with malloc resulting from the successive applications of f.
Returns the "fresh" string created from the successive applications of f.
int ft_strequ(char const *s1, char const *s2)
Lexicographical comparison between s1 and s2. If the 2 strings are identical the function returns 1, or 0 otherwise.
Returns 1 or 0 according to if the 2 strings are identical or not.
int ft_strnequ(char const *s1, char const *s2, size_t n)
Lexicographical comparison between s1 and s2 up to n characters or until a '\0' is reached. If the 2 strings are identical, the function returns 1, or 0 otherwise.
Returns 1 or 0 according to if the 2 strings are identical or not.
char * ft_strsub(char const *s, unsigned int start, size_t len)
Allocates with malloc and returns a "fresh" substring from the string given as argument. The substring begins at indexstart and is of size len. If start and len aren’t refering to a valid substring, the behavior is undefined. If the allocation fails, the function returns NULL.
Returns the substring.
char * ft_strjoin(char const *s1, char const *s2)
Allocates with malloc and returns a “fresh” string ending with ’\0’, result of the concatenation of s1 and s2. If the allocation fails the function returns NULL.
Returns the "fresh" string result of the concatenation of the 2 strings.
char * ft_strtrim(char const *s)
Allocates with malloc and returns a copy of the string given as argument without whitespaces at the beginning or at the end of the string. Will be considered as whitespaces the following characters ' ', '\n' and '\t'. If s has no whitespaces at the beginning or at the end, the function returns a copy of s. If the allocation fails the function returns NULL.
Returns the "fresh" trimmed string or a copy of s.
char ** ft_strsplit(char const *s, char c)
Allocates with malloc and returns an array of "fresh" strings (all ending with '\0', including the array itself) obtained by spliting s using the character c as a delimiter. If the allocation fails the function returns NULL.
Returns the array of "fresh" strings result of the split.
char * ft_itoa(int n)
Allocate with malloc and returns a "fresh" string ending with '\0' representing the integer n given as argument. Negative numbers must be supported. If the allocation fails, the function returns NULL.
Returns the string representing the integer passed as argument.
void ft_putchar(char c)
Outputs the character c to the standard output.
None.
void ft_putstr(char const *s)
Outputs the string s to the standard output.
None.
void ft_putendl(char const *s)
Outputs the string s to the standard output followed by a '\n'.
None.
void ft_putnbr(int n)
Outputs the integer n to the standard output.
None.
void ft_putchar_fd(char c, int fd)
Outputs the char c to the file descriptor fd.
None.
void ft_putstr_fd(char const *s, int fd)
Outputs the string s to the file descriptor fd.
None.
void ft_putendl_fd(char const *s, int fd)
Outputs the string s to the file descriptor fd followed by a '\n'.
None.
void ft_putnbr_fd(int n, int fd)
Outputs the integer n to the file descriptor fd.
None.
t_list * ft_lstnew(void const *content, size_t content_size)
Allocates with malloc and returns a "fresh" link. The variables content and content_size of the new link are initialized by copy of the parameters of the function. If the parameter content is nul, the variable content is initialized to NULL and the variable content_size is initialized to 0 even if the parameter content_size isn’t. The variable next is initialized to NULL. If the allocation fails, the function returns NULL.
Returns the new list.
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t))
Takes as a parameter a link’s pointer address and frees the memory of the link’s content using the function del given as a parameter, then frees the link’s memory using free. The memory of next must not be freed under any circumstance. Finally, the pointer to the link that was just freed must be set to NULL (quite similar to the function ft_memdel in the mandatory part).
None.
void ft_lstdel(t_list **alst, void (*del)(void *, size_t))
Takes as a parameter the adress of a pointer to a link and frees the memory of this link and every successors of that link using the functions del and free(3). Finally the pointer to the link that was just freed must be set to NULL (quite similar to the function ft_memdel from the mandatory part).
None.
void ft_lstadd(t_list **alst, t_list *new)
Adds the element new at the beginning of the list.
None.
void ft_lstiter(t_list *lst, void (*f)(t_list *elem))
Iterates the list lst and applies the function f to each link.
None.
t_list * ft_lstmap(t_list *lst, t_list * (*f)(t_list *elem))
Iterates a list lst and applies the function f to each link to create a “fresh” list (using malloc(3)) resulting from the successive applications of f. If the allocation fails, the function returns NULL.
Returns the new list.