From 5be302a3f8a2eae5daa3a60e1deed2c4ba121fe9 Mon Sep 17 00:00:00 2001 From: WOLFIE-OG Date: Mon, 1 Jul 2024 16:29:13 +0100 Subject: [PATCH] Update --- Makefile | 3 ++- include/libft.h | 3 ++- src/list/ft_lstpop.c | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/list/ft_lstpop.c diff --git a/Makefile b/Makefile index cd425eb..a6a3595 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: otodd +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/02/13 17:49:05 by otodd #+# #+# # -# Updated: 2024/06/28 14:13:16 by otodd ### ########.fr # +# Updated: 2024/07/01 15:38:35 by otodd ### ########.fr # # # # **************************************************************************** # @@ -133,6 +133,7 @@ LIST_SRCS = $(LIST_DIR)/ft_lstnew.c \ $(LIST_DIR)/ft_lstclear_rev.c \ $(LIST_DIR)/ft_lstfirst.c \ $(LIST_DIR)/ft_lstiter_rev.c \ + $(LIST_DIR)/ft_lstpop.c \ UTIL_SRCS = $(UTIL_DIR)/ft_numlen.c \ $(UTIL_DIR)/ft_range.c \ diff --git a/include/libft.h b/include/libft.h index 6ebbfa7..bb7db0d 100644 --- a/include/libft.h +++ b/include/libft.h @@ -6,7 +6,7 @@ /* By: otodd +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/16 18:36:11 by otodd #+# #+# */ -/* Updated: 2024/06/28 14:12:06 by otodd ### ########.fr */ +/* Updated: 2024/07/01 15:44:28 by otodd ### ########.fr */ /* */ /* ************************************************************************** */ @@ -106,6 +106,7 @@ int ft_lstsize(t_list *lst); void ft_lstiter_rev(t_list *lst, void (*f)(void *)); t_list *ft_lstfirst(t_list *lst); void ft_lstclear_rev(t_list **lst, void (*del)(void *)); +t_list *ft_lstpop(t_list *node); // Math Functions diff --git a/src/list/ft_lstpop.c b/src/list/ft_lstpop.c new file mode 100644 index 0000000..bc64930 --- /dev/null +++ b/src/list/ft_lstpop.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstpop.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: otodd +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/07/01 14:08:10 by otodd #+# #+# */ +/* Updated: 2024/07/01 15:40:56 by otodd ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../../include/libft.h" + +t_list *ft_lstpop(t_list *node) +{ + if (!node) + return (NULL); + if (node->next) + node->next->previous = node->previous; + if (node->previous) + node->previous->next = node->next; + return (node); +}