en cours de debuggage pour le probleme de free
This commit is contained in:
32
srcs/print.c
32
srcs/print.c
@@ -1,10 +1,35 @@
|
||||
|
||||
#include "push_swap.h"
|
||||
|
||||
void print_test(t_list *lst, char *s)
|
||||
{
|
||||
t_stack **tmpa;
|
||||
t_stack **tmpb;
|
||||
t_stack *a;
|
||||
t_stack *b;
|
||||
|
||||
tmpa = lst->content;
|
||||
tmpb = lst->next->content;
|
||||
a = *tmpa;
|
||||
b = *tmpb;
|
||||
ft_printf("%s -> a: %12i . %12i . ", s, tmpa, a);
|
||||
if (a)
|
||||
ft_printf("%12i", a->n);
|
||||
else
|
||||
ft_printf(" NULL");
|
||||
ft_printf(" | b: %12i . %12i . ", tmpb, b);
|
||||
if (b)
|
||||
ft_printf("%12i \n", b->n);
|
||||
else
|
||||
ft_printf(" NULL\n");
|
||||
|
||||
//ft_printf("%s -> a: %i , %i , %i / b: %i , %i, %i \n", s, tmpa, a, a->n, tmpb, b, b->n);
|
||||
}
|
||||
|
||||
/*
|
||||
** this function is called at each action (pushes, swapes, rotates)
|
||||
** pointers to the stacks a and b are stored into two first element of list solution (because both lists a and b are not available from every functions, like sa() doesn't receive b in argument)
|
||||
** the function access the list to fill a new element with three things :
|
||||
** the function access the list after the two first elements to fill a new element with three things :
|
||||
** - the name of the action (sa, sp, rra, etc)
|
||||
** - the stack a
|
||||
** - the stack b
|
||||
@@ -23,13 +48,14 @@ void fill_solution(t_list *solution, char *sp)
|
||||
t_stack *b;
|
||||
char *stack;
|
||||
|
||||
print_test(solution, "fill_solution (beginning)");
|
||||
tmp1 = solution->content;
|
||||
tmp2 = solution->next->content;
|
||||
a = *tmp1;
|
||||
b = *tmp2;
|
||||
stack = ft_strdup(sp);
|
||||
stack = ft_strjoinfree(stack, ft_strdup("!a:"));
|
||||
while(a)
|
||||
while(a != NULL)
|
||||
{
|
||||
stack = ft_strjoinfree(stack, ft_strdup(" "));
|
||||
stack = ft_strjoinfree(stack, ft_itoa(a->n));
|
||||
@@ -42,7 +68,9 @@ void fill_solution(t_list *solution, char *sp)
|
||||
stack = ft_strjoinfree(stack, ft_itoa(b->n));
|
||||
b = b->next;
|
||||
}
|
||||
print_test(solution, "fill_solu. (bfr add_back)");
|
||||
ft_lstadd_back(&solution, ft_lstnew(stack));
|
||||
print_test(solution, "fill_solu. (aft add_back)");
|
||||
}
|
||||
|
||||
void print_result(t_list *result, int flag)
|
||||
|
||||
Reference in New Issue
Block a user