Skip to content

Commit

Permalink
implement wrapper clear_stack
Browse files Browse the repository at this point in the history
  • Loading branch information
rask24 committed Jan 23, 2024
1 parent c6d2ca8 commit e1fa1b5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ SRC = $(SRC_DIR)/main.c \
$(SRC_DIR)/stack_operations/ft_lst_before.c \
$(SRC_DIR)/utils/first_content.c \
$(SRC_DIR)/utils/second_content.c \
$(SRC_DIR)/utils/exit_with_error.c
$(SRC_DIR)/utils/exit_with_error.c \
$(SRC_DIR)/utils/clear_stack.c
OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC))
DEP = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.d, $(SRC))
OBJ_FILTER_MAIN = $(filter-out $(BUILD_DIR)/main.o, $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC)))
Expand Down
3 changes: 2 additions & 1 deletion include/push_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/10 12:37:54 by reasuke #+# #+# */
/* Updated: 2024/01/23 15:25:01 by reasuke ### ########.fr */
/* Updated: 2024/01/23 15:51:40 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -48,5 +48,6 @@ t_list *ft_lst_before(t_list *lst, t_list *trg);
int first_content(t_stack **p_stack);
int second_content(t_stack **p_stack);
void exit_with_error(void);
void clear_stack(t_stack **p_stack, void (*del)(void *));

#endif
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/10 12:37:36 by reasuke #+# #+# */
/* Updated: 2024/01/23 15:33:21 by reasuke ### ########.fr */
/* Updated: 2024/01/23 15:48:43 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -41,6 +41,6 @@ int main(int argc, char **argv)
a = generate_stack(argc, argv);
b = NULL;
sort(&a, &b, argc - 1);
ft_lstclear(&a, free);
clear_stack(&a, free);
return (0);
}
18 changes: 18 additions & 0 deletions src/utils/clear_stack.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* clear_stack.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/23 15:46:24 by reasuke #+# #+# */
/* Updated: 2024/01/23 15:47:39 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"

void clear_stack(t_stack **p_stack, void (*del)(void *))
{
ft_lstclear(p_stack, del);
}

0 comments on commit e1fa1b5

Please sign in to comment.