add day 14 and try part2 with mlx (didn't work)

This commit is contained in:
2024-12-14 15:17:44 +01:00
parent 4342ae314e
commit 7dfe1cb9f3
131 changed files with 3142 additions and 0 deletions

41
2024/14/libft/ft_lstmap.c Executable file
View File

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/01 17:29:05 by tomoron #+# #+# */
/* Updated: 2023/11/02 11:47:05 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
{
t_list *res;
t_list *current;
if (!lst)
return (0);
res = malloc(sizeof(t_list));
if (!res)
return (0);
res -> content = f(lst->content);
lst = lst->next;
current = res;
while (lst)
{
current->next = malloc(sizeof(t_list));
if (!current->next)
{
ft_lstclear(&res, del);
return (0);
}
current = current->next;
current->content = f(lst->content);
lst = lst->next;
}
current->next = NULL;
return (res);
}