gestion doublons ok

This commit is contained in:
hugogogo
2021-09-27 14:07:52 +02:00
parent 60752e2faf
commit 2d37058a43
7 changed files with 57 additions and 27 deletions

View File

@@ -1,25 +1,18 @@
#include "push_swap.h"
void ps_error(int err)
{
if (err == 1)
ft_printf("usage :\nlaunch executable : ./push_swap [flag -p] nb nb nb nb nb ...\n");
if (err >= 2)
ft_putstr_fd("Error\n", 2);
exit(0);
}
/*
** if err = 0, the list are freed but the program doesn't stop
** if err = 1, 2 or 3, a message is printed and the program stop
** if err = 3, the parameter list is just a t_stack *list
** if err = 3 ou -1, the parameter list is just a t_stack *list
*/
void ps_stop(t_list *lst, int err)
void ps_stop(char **tab, t_list *lst, int err)
{
t_stack **a;
t_stack **b;
if (err == 3)
if (tab != NULL)
ft_free_tab(tab);
if (err == 3 || err == -1)
ft_lstclear(&lst, NULL);
else if (lst)
{
@@ -32,5 +25,11 @@ void ps_stop(t_list *lst, int err)
ft_lstclear(&lst, free);
}
if (err > 0)
ps_error(err);
{
if (err == 1)
ft_printf("usage :\nlaunch executable : ./push_swap [flag -p] nb nb nb nb nb ...\n");
if (err >= 2)
ft_putstr_fd("Error\n", 2);
exit(0);
}
}