Skip to content

Latest commit

 

History

History
92 lines (74 loc) · 11.3 KB

README.md

File metadata and controls

92 lines (74 loc) · 11.3 KB

Libft

Hey ! This is my implementation of the libft header from 42 school (São Paulo - Brazil) !

The tests are already validated by the moulinette 🤖 :)

make

To compile and make some tests, it's necessary to run make all in the root folder. This will create the object files in the root directory, and the libft.a. The make fclean will erase all data created by make including the object files.

versions

For this particulary project, i used the clang version 13.0.1 to compile the code, and valgrind-3.19.0 to catch memory leaks.

run

To compile the test code using the library (after make), the command below can be used:

clang main.c -g -L . -lft -I . && ./a.out

or do like me, and create an alias to do all the job in a simple manner:

runlib='make re > /dev/null && clang main.c -g -L . -lft -I . && ./a.out'

This has to be configured in your initialization shell file to be make persistent. Generally ~/bashrc if you are using bash has your default shell.

functions

This is a brief summary for the functions that i have written.

Part 1

Name Description Parameters status 🤖
ft_isalpha Check if the caracter is alpha int ft_isalpha(int ch) ok 🟢
ft_isdigit Check if the caracter is a digit int ft_isdigit(int ch) ok 🟢
ft_isalnum Check if the caracter is a alphanumeric int ft_isalnum(int ch) ok 🟢
ft_isascii Check if the caracter is in the ascii table int ft_isascii(int ch) ok 🟢
ft_isprint Check if the caracter is printable int ft_isprint(int ch) ok 🟢
ft_strlen Find the size of the string ft_strlen(const char *s) ok 🟢
ft_memset Set the all bytes of the pointer to carcter caracter 'c'. void *ft_memset(void *s, int c, size_t n) ok 🟢
ft_bzero Set the all bytes of the pointer to zero. void ft_bzero(void *s, size_t n) ok 🟢
ft_memcpy Copy the bytes from one memory area to another void *ft_memcpy(void *dest, const void *src, size_t n) ok 🟢
ft_memmove Copy the bytes from one memory area to another (the areas may overlap) void *ft_memmove(void *dest, const void *src, size_t n) ok 🟢
ft_strlcpy Copy a string to an array size_t ft_strlcpy(char *dst, const char *src, size_t size) ok 🟢
ft_strlcat Concatenate a string to an array size_t ft_strlcat(char *dest, const char *src, size_t size) ok 🟢
ft_toupper If c is a lowercase letter, toupper() returns its uppercase equivalent int ft_toupper(int ch) ok 🟢
ft_tolower If c is an uppercase letter, tolower() returns its lowercase equivalent int ft_tolower(int ch) ok 🟢
ft_strchr returns a pointer to the first occurrence of the character c in the string s char *ft_strchr(const char *str, int ch) ok 🟢
ft_strrchr function returns a pointer to the last occurrence of the character c in the string s char *ft_strrchr(const char *str, int ch) ok 🟢
ft_strncmp Compares the two strings s1 and s2, and return an integer as result of the comparasion int ft_strncmp(const char *lhs, char *rhs, size_t count) ok 🟢
ft_memchr scans the initial n bytes of the memory area pointed to by s for the first instance of c void *ft_memchr(const void *s, int c, size_t n); ok 🟢
ft_strnstr locates the first occurrence of the string little in the string big char *ft_strnstr(const char *big, const char *little, size_t len); ok 🟢
ft_atoi transform an string to a int int ft_atoi(const char *str); ok 🟢
ft_calloc Allocates memory for an array of num elements of size bytes void *ft_calloc(size_t num, size_t size); ok 🟢
ft_strdup returns a pointer to a new string which is a du‐plicate of the string s char *ft_strdup(const char *s); ok 🟢

Part 2

Name Description Parameters status 🤖
ft_substr returns a substring from the string ’s’ char *ft_substr(char const *s, unsigned int start, size_t len); ok 🟢
ft_strjoin returns a new string, which is the result of the concatenation of ’s1’ and ’s2’. char *ft_substr(char const *s, unsigned int start, size_t len)ft_strjoin; ok 🟢
ft_strtrim returns a copy of ’s1’ with the characters in ’set’ removed from the beginning and the end. char *ft_strtrim(char const *s1, char const *set); ok 🟢
ft_split returns an array of strings obtained by splitting ’s’ using the character ’c’ as a delimiter. char **ft_split(char const *s, char c); ok 🟢
ft_itoa returns a string representing the integer received as an argument. char *ft_itoa(int n); ok 🟢
ft_strmapi Applies the function ’f’ to each character of the string ’s’ char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); ok 🟢
ft_striteri Applies the function ’f’ on each character of the string passed as argument void ft_striteri(char *s, void (*f)(unsigned int, char*)); ok 🟢
ft_putchar_fd Outputs the character ’c’ to the given file descriptor. void ft_putchar_fd(char c, int fd); ok 🟢
ft_putstr_fd Outputs the string ’s’ to the given file descriptor. void ft_putstr_fd(char *s, int fd); ok 🟢
ft_putendl_fd Outputs the string ’s’ to the given file descriptor followed by a newline. void ft_putendl_fd(char *s, int fd); ok 🟢
ft_putnbr_fd Outputs the integer ’n’ to the given file descriptor. void ft_putnbr_fd(int n, int fd); ok 🟢

Bonus

Name Description Parameters status 🤖
ft_lstnew Allocates and returns a new node in the list. t_list *ft_lstnew(void *content); ok 🟢
ft_lstadd_front Adds the node ’new’ at the beginning of the list. void ft_lstadd_front(t_list **lst, t_list *new); ok 🟢
ft_lstsize Counts the number of nodes in a list. int ft_lstsize(t_list *lst); ok 🟢
ft_lstlast Returns the last node of the list. t_list *ft_lstlast(t_list *lst); ok 🟢
ft_lstadd_back Adds the node ’new’ at the end of the list. void ft_lstadd_back(t_list **lst, t_list *new); ok 🟢
ft_lstdelone Frees the memory ofthe node’s content using the function ’del’ void ft_lstdelone(t_list *lst, void (*del)(void*)); ok 🟢
ft_lstclear Deletes and frees the given node and every successor of that node void ft_lstclear(t_list **lst, void (*del)(void*)); ok 🟢
ft_lstiter Iterates the list ’lst’ and applies the function ’f’ on the content of each node. void ft_lstiter(t_list *lst, void (*f)(void *)); ok 🟢
ft_lstmap Iterates the list ’lst’ and applies the function ’f’. Creates a new list resulting the applications t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)); ok 🟢

Contact

Feel free to hit me to talk about the code.

linkedin

“I'd far rather be happy than right any day.”