segfault bizare dans la fonctions qui verifie que la liste est ordonnee
This commit is contained in:
@@ -1,5 +1,21 @@
|
||||
#include "push_swap.h"
|
||||
|
||||
int is_ordered(t_stack *list)
|
||||
{
|
||||
int cmp;
|
||||
|
||||
cmp = list->n;
|
||||
while (list->next != NULL)
|
||||
{
|
||||
list = list->next;
|
||||
ft_printf("n:%i cmp:%i\n", cmp, list->n);
|
||||
if (list->n < cmp)
|
||||
return (0);
|
||||
cmp = list->n;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int check_flag(int *ac, char ***av)
|
||||
{
|
||||
if (ft_strcmp((*av)[1], "-p") == 0)
|
||||
@@ -55,6 +71,7 @@ t_stack *init_stack(int ac, char **av)
|
||||
i++;
|
||||
while (--i >= 0)
|
||||
list = fill_stack(list, split[i]);
|
||||
ft_free_tab(split);
|
||||
}
|
||||
return (list);
|
||||
}
|
||||
@@ -96,8 +113,11 @@ int main(int ac, char **av)
|
||||
flag = check_flag(&ac, &av);
|
||||
a = init_stack(ac, av);
|
||||
b = NULL;
|
||||
solution = launch_algo(&a, &b, flag);
|
||||
print_result(solution, flag);
|
||||
if (is_ordered(a) == 1)
|
||||
{
|
||||
solution = launch_algo(&a, &b, flag);
|
||||
print_result(solution, flag);
|
||||
}
|
||||
ps_stop(solution, 0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user