purge ancien files et mise a jour libftH

This commit is contained in:
Hugo LAMY
2019-11-25 15:46:21 +01:00
parent b6e9b9e5e6
commit 96c7ce814e
182 changed files with 239 additions and 2718 deletions

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:11:53 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:11:57 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:36:12 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,19 +15,19 @@
** or first if list has no element so far
*/
/*
/*
** #include <libc.h>
**
**
** typedef struct s_list
** {
** void *content;
** struct s_list *next;
** } t_list;
**
**
** t_list *ft_lstnew(void *content)
** {
** t_list *lst;
**
**
** if (!(lst = (t_list *)malloc(sizeof(*lst))))
** return (NULL);
** if (!content)
@@ -37,9 +37,9 @@
** lst->next = NULL;
** return (lst);
** }
**
**
** void ft_lstadd_back(t_list **alst, t_list *new);
**
**
** int main(void)
** {
** char tresor;
@@ -47,7 +47,7 @@
** char friends;
** t_list *toto;
** t_list *tmp;
**
**
** tresor = 'a';
** matos = 'b';
** friends = 'c';
@@ -67,7 +67,7 @@
** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next));
** return (0);
** }
*/
*/
#include "libft.h"
@@ -89,4 +89,3 @@ void ft_lstadd_back(t_list **alst, t_list *new)
new->next = NULL;
}
}

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:12:02 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:13:14 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:36:54 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,21 +14,21 @@
** add an element to the begining of a list
*/
/*
/*
** #include <libc.h>
**
**
** typedef struct s_list
** {
** void *content;
** struct s_list *next;
** } t_list;
**
**
** void *ft_memcpy(void *dst, const void *src, size_t n)
** {
** size_t i;
** char *ptr;
** char *ptr2;
**
**
** ptr = (char *)dst;
** ptr2 = (char *)src;
** i = -1;
@@ -36,11 +36,11 @@
** ptr[i] = ptr2[i];
** return (dst);
** }
**
**
** t_list *ft_lstnew(void *content)
** {
** t_list *lst;
**
**
** if (!(lst = (t_list *)malloc(sizeof(*lst))))
** return (NULL);
** if (!content)
@@ -54,9 +54,9 @@
** lst->next = NULL;
** return (lst);
** }
**
**
** void ft_lstadd_front(t_list **alst, t_list *new);
**
**
** int main(void)
** {
** char tresor;
@@ -64,7 +64,7 @@
** char friends;
** t_list *toto;
** t_list *tmp;
**
**
** tresor = 'a';
** matos = 'b';
** friends = 'c';
@@ -83,7 +83,7 @@
** printf("toto->nxt->nxt->dqta:%c\n",*(char*)(toto->next->next->content));
** return (0);
** }
*/
*/
#include "libft.h"

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:13:30 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:13:49 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:31:30 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,19 +14,19 @@
** delete and free an element of the list and all the followings
*/
/*
/*
** #include <libc.h>
**
**
** typedef struct s_list
** {
** void *content;
** struct s_list *next;
** } t_list;
**
**
** t_list *ft_lstnew(void *content)
** {
** t_list *lst;
**
**
** if (!(lst = (t_list *)malloc(sizeof(*lst))))
** return (NULL);
** if (!content)
@@ -36,11 +36,11 @@
** lst->next = NULL;
** return (lst);
** }
**
**
** void ft_lstadd_back(t_list **alst, t_list *new)
** {
** t_list *tmp;
**
**
** if (alst)
** {
** tmp = *alst;
@@ -55,26 +55,26 @@
** new->next = NULL;
** }
** }
**
**
** void ft_delete(void *element)
** {
** *(char*)element = '\0';
** }
**
**
** void ft_lstdelone(t_list *lst, void (*del)(void *))
** {
** del(lst->content);
** free(lst);
** lst = NULL;
** }
**
**
** void ft_lstclear(t_list **lst, void (*del)(void *));
**
**
** int main(void)
** {
** t_list *toto;
** void (ft_delete)(void*);
**
**
** printf("sizeof(t_list)%lu\n",sizeof(t_list));
** toto = ft_lstnew("a");
** toto->next = ft_lstnew("b");
@@ -90,7 +90,7 @@
** printf("toto->nxt->nxt :%s\n",(char*)(toto->next->next));
** return (0);
** }
*/
*/
#include "libft.h"

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:14:03 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:14:05 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:35:53 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,19 +15,19 @@
** next is not free
*/
/*
/*
** #include <libc.h>
**
**
** typedef struct s_list
** {
** void *content;
** struct s_list *next;
** } t_list;
**
**
** t_list *ft_lstnew(void *content)
** {
** t_list *lst;
**
**
** if (!(lst = (t_list *)malloc(sizeof(*lst))))
** return (NULL);
** if (!content)
@@ -37,11 +37,11 @@
** lst->next = NULL;
** return (lst);
** }
**
**
** void ft_lstadd_back(t_list **alst, t_list *new)
** {
** t_list *tmp;
**
**
** if (alst)
** {
** tmp = *alst;
@@ -56,19 +56,19 @@
** new->next = NULL;
** }
** }
**
**
** void ft_delete(void *element)
** {
** *(char*)element = '\0';
** }
**
**
** void ft_lstdelone(t_list *lst, void (*del)(void *));
**
**
** int main(void)
** {
** t_list *toto;
** void (ft_delete)(void*);
**
**
** toto = ft_lstnew("a");
** toto->next = ft_lstnew("b");
** toto->next->next = ft_lstnew("c");
@@ -84,9 +84,9 @@
** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next));
** return (0);
** }
*/
*/
//#include "libft.h"
#include "libft.h"
void ft_lstdelone(t_list *lst, void (*del)(void *))
{

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:14:11 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:14:29 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:34:59 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,19 +14,19 @@
** go through all elements of the list and apply the function f to each of them
*/
/*
/*
** #include <libc.h>
**
**
** typedef struct s_list
** {
** void *content;
** struct s_list *next;
** } t_list;
**
**
** t_list *ft_lstnew(void *content)
** {
** t_list *lst;
**
**
** if (!(lst = (t_list *)malloc(sizeof(*lst))))
** return (NULL);
** if (!content)
@@ -36,9 +36,9 @@
** lst->next = NULL;
** return (lst);
** }
**
**
** void ft_lstiter(t_list *lst, void (*f)(void*));
**
**
** void to_uppercase(void *element)
** {
** // *(char*)(((t_list*)element)->content) -= 32;
@@ -48,11 +48,12 @@
** tmp = (t_list*)element;
** *(char*)(tmp->content) -= 32;
** }
**
** int main(void)
** {
** t_list *toto;
** void to_uppercase(void*);
**
**
** toto = ft_lstnew("a");
** toto->next = ft_lstnew("b");
** toto->next->next = ft_lstnew("c");
@@ -68,7 +69,7 @@
** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next));
** return (0);
** }
*/
*/
#include "libft.h"

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:14:49 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:15:36 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:30:20 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,21 +14,21 @@
** return a pointer to the last element of a list
*/
/*
/*
** #include <libc.h>
**
**
** typedef struct s_list
** {
** void *content;
** struct s_list *next;
** } t_list;
**
**
** void *ft_memcpy(void *dst, const void *src, size_t n)
** {
** size_t i;
** char *ptr;
** char *ptr2;
**
**
** ptr = (char *)dst;
** ptr2 = (char *)src;
** i = -1;
@@ -36,11 +36,11 @@
** ptr[i] = ptr2[i];
** return (dst);
** }
**
**
** t_list *ft_lstnew(void *content)
** {
** t_list *lst;
**
**
** if (!(lst = (t_list *)malloc(sizeof(*lst))))
** return (NULL);
** if (!content)
@@ -54,21 +54,21 @@
** lst->next = NULL;
** return (lst);
** }
**
**
** void ft_lstadd_front(t_list **alst, t_list *new)
** {
** new->next = *alst;
** *alst = new;
** }
**
**
** t_list *ft_lstlast(t_list *lst);
**
**
** int main(void)
** {
** char tresor;
** t_list *toto;
** t_list *tmp;
**
**
** tresor = 'a';
** toto = ft_lstnew(&tresor);
** tresor = 'b';
@@ -87,7 +87,7 @@
** printf("toto->nxt->nxt->data:%c\n",*(char*)(toto->next->next->content));
** return (0);
** }
*/
*/
#include "libft.h"

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:15:42 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:16:15 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:34:19 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,19 +15,19 @@
** if necessary the function del is used to delete an element
*/
/*
/*
** #include <libc.h>
**
**
** typedef struct s_list
** {
** void *content;
** struct s_list *next;
** } t_list;
**
**
** t_list *ft_lstnew(void *content)
** {
** t_list *lst;
**
**
** if (!(lst = (t_list *)malloc(sizeof(*lst))))
** return (NULL);
** if (!content)
@@ -37,11 +37,11 @@
** lst->next = NULL;
** return (lst);
** }
**
**
** void ft_lstadd_back(t_list **alst, t_list *new)
** {
** t_list *tmp;
**
**
** if (alst)
** {
** tmp = *alst;
@@ -56,26 +56,26 @@
** new->next = NULL;
** }
** }
**
**
** void *to_uppercase(void *element)
** {
** *(char*)(((t_list*)element)->content) -= 32;
** return (element);
** }
**
**
** void ft_delete(void *element)
** {
** *(char*)element = '\0';
** }
**
**
** t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
**
**
** int main(void)
** {
** t_list *toto;
** void *(to_uppercase)(void *);
** void (ft_delete)(void*);
**
**
** toto = ft_lstnew("a");
** toto->next = ft_lstnew("b");
** toto->next->next = ft_lstnew("c");
@@ -91,7 +91,7 @@
** printf("toto->nxt->nxt->nxt :%s\n",(char*)(toto->next->next->next));
** return (0);
** }
*/
*/
#include "libft.h"

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:16:20 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:16:30 by hulamy ### ########.fr */
/* Updated: 2019/11/25 14:29:46 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,22 +14,22 @@
** create a new list
*/
/*
/*
** #include <libc.h>
**
**
** typedef struct s_list
** {
** void *content;
** struct s_list *next;
** } t_list;
**
**
** t_list *ft_lstnew(void *content);
**
**
** int main(void)
** {
** char tresor;
** t_list *toto;
**
**
** tresor = 'd';
** printf("tresor : %c\n",tresor);
** toto = ft_lstnew(&tresor);
@@ -40,7 +40,7 @@
** printf("and also toto->content: %c\n",*(char*)(toto->content));
** return (0);
** }
*/
*/
#include "libft.h"

View File

@@ -1,16 +1,32 @@
/*
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:31:48 by hulamy #+# #+# */
/* Updated: 2019/11/25 14:32:30 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** return the size of the linked list
*/
/*
** #include <libc.h>
**
**
** typedef struct s_list
** {
** void *content;
** struct s_list *next;
** } t_list;
**
**
** t_list *ft_lstnew(void *content)
** {
** t_list *lst;
**
**
** if (!(lst = (t_list *)malloc(sizeof(*lst))))
** return (NULL);
** if (!content)
@@ -20,21 +36,21 @@
** lst->next = NULL;
** return (lst);
** }
**
**
** void ft_lstadd_front(t_list **alst, t_list *new)
** {
** new->next = *alst;
** *alst = new;
** }
**
**
** int ft_lstsize(t_list *lst);
**
**
** int main(void)
** {
** char tresor;
** t_list *toto;
** t_list *tmp;
**
**
** tresor = 'a';
** toto = ft_lstnew(&tresor);
** tresor = 'b';
@@ -52,7 +68,7 @@
** printf("toto->nxt->nxt->dqta:%c\n",*(char*)(toto->next->next->content));
** return (0);
** }
*/
*/
#include "libft.h"