From: Lukáš Jiřiště Date: Mon, 6 Apr 2026 10:59:35 +0000 (+0200) Subject: Remove ft_stack_pop_forget X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=6cc8564c55e713c839558df6b0d5b738930af0c6;p=Libft.git Remove ft_stack_pop_forget I do not understand, why the standard pop should call free on the element as that would make it quite useless. Hence I removed the element free from pop, which became the same as pop_forget. --- diff --git a/Makefile b/Makefile index 1f8b8a2..ae34993 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ SRCDIR := ft_gen ft_math ft_str ft_mem ft_io ft_check ft_conv \ SRCstruct:= ft_stack_free.c \ ft_stack_init.c \ ft_stack_pop.c \ - ft_stack_pop_forget.c \ ft_stack_push.c \ ft_stack_top.c \ ft_tree_init.c \ diff --git a/ft_parse/actions.c b/ft_parse/actions.c index 1138708..cd5001f 100644 --- a/ft_parse/actions.c +++ b/ft_parse/actions.c @@ -59,7 +59,7 @@ static int hang_top_from_tree(t_stack *stack, t_parse_tree_node *tree, node->token = ft_token_dup(&g_empty_token); } else - node = ((t_parser_stack_element *)ft_stack_pop(stack, NULL))->node; + node = ((t_parser_stack_element *)ft_stack_pop(stack))->node; if (ft_strcmp(node->token.type, constituent_token->type) || ft_vec_insert(&tree->children, node, 0) != success) { diff --git a/ft_struct/ft_llist.c b/ft_struct/ft_llist.c index b7e33b2..54ff25c 100644 --- a/ft_struct/ft_llist.c +++ b/ft_struct/ft_llist.c @@ -8,6 +8,7 @@ t_ft_stat ft_llist_init(t_llist *list, size_t el_size) return (invalid_input); list->el_size = el_size; list->head = NULL; + list->tail = NULL; return (success); } diff --git a/ft_struct/ft_rbtree_traversal.c b/ft_struct/ft_rbtree_traversal.c index 8e022d6..7c5ea9a 100644 --- a/ft_struct/ft_rbtree_traversal.c +++ b/ft_struct/ft_rbtree_traversal.c @@ -125,7 +125,7 @@ void *ft_rbtree_traverse(t_rbtree_traversal *traversal) { t_rbtree_node **node; - node = ft_stack_pop_forget(&traversal->stack); + node = ft_stack_pop(&traversal->stack); if (node && *node) return (&(*node)->data); ft_rbtree_traversal_free(traversal); diff --git a/ft_struct/ft_stack_pop.c b/ft_struct/ft_stack_pop.c index 0f2ce9f..a9db28c 100644 --- a/ft_struct/ft_stack_pop.c +++ b/ft_struct/ft_stack_pop.c @@ -13,11 +13,11 @@ #include "ft_struct.h" #include "ft_arr.h" -void *ft_stack_pop(t_stack *stack, void (*free_el)(void *)) +void *ft_stack_pop(t_stack *stack) { void *res; res = ft_stack_top(stack); - ft_llist_delete_head(&stack->list, free_el); + ft_llist_delete_head(&stack->list, NULL); return (res); } diff --git a/ft_struct/ft_stack_pop_forget.c b/ft_struct/ft_stack_pop_forget.c deleted file mode 100644 index 3d51c67..0000000 --- a/ft_struct/ft_stack_pop_forget.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_stack_pop_forget.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ljiriste +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/06/20 17:15:41 by ljiriste #+# #+# */ -/* Updated: 2024/06/20 17:47:35 by ljiriste ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_struct.h" -#include "ft_arr.h" - -void *ft_stack_pop_forget(t_stack *stack) -{ - return (ft_stack_pop(stack, NULL)); -} diff --git a/inc/ft_struct.h b/inc/ft_struct.h index 3d5dcb5..1495cbf 100644 --- a/inc/ft_struct.h +++ b/inc/ft_struct.h @@ -57,8 +57,7 @@ typedef struct s_stack t_ft_stat ft_stack_init(t_stack *stack, size_t el_size); t_ft_stat ft_stack_push(t_stack *stack, void *element); void *ft_stack_top(t_stack *stack); -void *ft_stack_pop(t_stack *stack, t_free_fun free_el); -void *ft_stack_pop_forget(t_stack *stack); +void *ft_stack_pop(t_stack *stack); void ft_stack_free(t_stack *stack, t_free_fun free_el); // t_vec reserves memory for 8 elements at first