finish my bonus and not doing the valgrind

This commit is contained in:
Maoake Teriierooiterai
2026-01-14 11:52:32 +01:00
parent e8b2a90dc1
commit 29c60fef6a
5 changed files with 26 additions and 26 deletions

View File

@@ -18,27 +18,27 @@
static int apply_operation(t_stacks *stacks, char buf[1024]) static int apply_operation(t_stacks *stacks, char buf[1024])
{ {
if (!ft_strncmp("sa", buf, ft_strlen(buf))) if (ft_strncmp("sa\n", buf, ft_strlen(buf)))
return (sa(stacks), 1); return (sa(stacks), 1);
if (!ft_strncmp("sb", buf, ft_strlen(buf))) if (ft_strncmp("sb\n", buf, ft_strlen(buf)))
return (sb(stacks), 1); return (sb(stacks), 1);
if (!ft_strncmp("ss", buf, ft_strlen(buf))) if (ft_strncmp("ss\n", buf, ft_strlen(buf)))
return (ss(stacks), 1); return (ss(stacks), 1);
if (!ft_strncmp("pa", buf, ft_strlen(buf))) if (ft_strncmp("pa\n", buf, ft_strlen(buf)))
return (pa(stacks), 1); return (pa(stacks), 1);
if (!ft_strncmp("pb", buf, ft_strlen(buf))) if (ft_strncmp("pb\n", buf, ft_strlen(buf)))
return (pb(stacks), 1); return (pb(stacks), 1);
if (!ft_strncmp("ra", buf, ft_strlen(buf))) if (ft_strncmp("ra\n", buf, ft_strlen(buf)))
return (ra(stacks), 1); return (ra(stacks), 1);
if (!ft_strncmp("rb", buf, ft_strlen(buf))) if (ft_strncmp("rb\n", buf, ft_strlen(buf)))
return (rb(stacks), 1); return (rb(stacks), 1);
if (!ft_strncmp("rr", buf, ft_strlen(buf))) if (ft_strncmp("rr\n", buf, ft_strlen(buf)))
return (rr(stacks), 1); return (rr(stacks), 1);
if (!ft_strncmp("rra", buf, ft_strlen(buf))) if (ft_strncmp("rra\n", buf, ft_strlen(buf)))
return (rra(stacks), 1); return (rra(stacks), 1);
if (!ft_strncmp("rrb", buf, ft_strlen(buf))) if (ft_strncmp("rrb\n", buf, ft_strlen(buf)))
return (rrb(stacks), 1); return (rrb(stacks), 1);
if (!ft_strncmp("rrr", buf, ft_strlen(buf))) if (ft_strncmp("rrr\n", buf, ft_strlen(buf)))
return (rrr(stacks), 1); return (rrr(stacks), 1);
return (0); return (0);
} }
@@ -63,10 +63,10 @@ static int tester(t_stacks *stacks)
buf = get_next_line(0); buf = get_next_line(0);
} }
if (!is_stacks_b_empty(stacks)) if (!is_stacks_b_empty(stacks))
return (write(1, "KO\n", 3)); return (secure_write(1, "KO\n", 3));
if (!check_order(stacks->a)) if (!check_order(stacks->a))
return (write(1, "KO\n", 3)); return (secure_write(1, "KO\n", 3));
write(1, "OK\n", 3); secure_write(1, "OK\n", 3);
return (0); return (0);
} }
@@ -96,7 +96,7 @@ int main(int argc, char **argv)
if (!tab) if (!tab)
return (0); return (0);
if (!check_error_bonus(tab)) if (!check_error_bonus(tab))
write(2, "Error\n", 7); secure_write(2, "Error\n", 7);
else else
bonus(tab); bonus(tab);
free_tab(tab); free_tab(tab);

View File

@@ -32,7 +32,7 @@ void pa(t_stacks *stacks)
stack_add_front(&(stacks->a), b_push); stack_add_front(&(stacks->a), b_push);
stacks->pa++; stacks->pa++;
if (stacks->print) if (stacks->print)
write(1, "pa\n", 3); secure_write(1, "pa\n", 3);
} }
void pb(t_stacks *stacks) void pb(t_stacks *stacks)
@@ -53,5 +53,5 @@ void pb(t_stacks *stacks)
stack_add_front(&(stacks->b), a_push); stack_add_front(&(stacks->b), a_push);
stacks->pb++; stacks->pb++;
if (stacks->print) if (stacks->print)
write(1, "pb\n", 3); secure_write(1, "pb\n", 3);
} }

View File

@@ -18,7 +18,7 @@ void rra(t_stacks *stacks)
if (stacks && stacks->a && stacks->a->previous) if (stacks && stacks->a && stacks->a->previous)
stacks->a = stacks->a->previous; stacks->a = stacks->a->previous;
stacks->rra++; stacks->rra++;
write(1, "rra\n", 4); secure_write(1, "rra\n", 4);
} }
void rrb(t_stacks *stacks) void rrb(t_stacks *stacks)
@@ -27,7 +27,7 @@ void rrb(t_stacks *stacks)
stacks->b = stacks->b->previous; stacks->b = stacks->b->previous;
stacks->rrb++; stacks->rrb++;
if (stacks->print) if (stacks->print)
write(1, "rrb\n", 4); secure_write(1, "rrb\n", 4);
} }
void rrr(t_stacks *stacks) void rrr(t_stacks *stacks)
@@ -38,5 +38,5 @@ void rrr(t_stacks *stacks)
stacks->a = stacks->a->previous; stacks->a = stacks->a->previous;
stacks->rrr++; stacks->rrr++;
if (stacks->print) if (stacks->print)
write(1, "rrr\n", 4); secure_write(1, "rrr\n", 4);
} }

View File

@@ -19,7 +19,7 @@ void ra(t_stacks *stacks)
stacks->a = stacks->a->next; stacks->a = stacks->a->next;
stacks->ra++; stacks->ra++;
if (stacks->print) if (stacks->print)
write(1, "ra\n", 3); secure_write(1, "ra\n", 3);
} }
void rb(t_stacks *stacks) void rb(t_stacks *stacks)
@@ -28,7 +28,7 @@ void rb(t_stacks *stacks)
stacks->b = stacks->b->next; stacks->b = stacks->b->next;
stacks->rb++; stacks->rb++;
if (stacks->print) if (stacks->print)
write(1, "rb\n", 3); secure_write(1, "rb\n", 3);
} }
void rr(t_stacks *stacks) void rr(t_stacks *stacks)
@@ -39,5 +39,5 @@ void rr(t_stacks *stacks)
stacks->b = stacks->b->next; stacks->b = stacks->b->next;
stacks->rr++; stacks->rr++;
if (stacks->print) if (stacks->print)
write(1, "rr\n", 3); secure_write(1, "rr\n", 3);
} }

View File

@@ -26,7 +26,7 @@ void sa(t_stacks *stacks)
a->next->value = stock; a->next->value = stock;
stacks->sa++; stacks->sa++;
if (stacks->print) if (stacks->print)
write(1, "sa\n", 3); secure_write(1, "sa\n", 3);
} }
void sb(t_stacks *stacks) void sb(t_stacks *stacks)
@@ -42,7 +42,7 @@ void sb(t_stacks *stacks)
b->next->value = stock; b->next->value = stock;
stacks->sb++; stacks->sb++;
if (stacks->print) if (stacks->print)
write(1, "sb\n", 3); secure_write(1, "sb\n", 3);
} }
void ss(t_stacks *stacks) void ss(t_stacks *stacks)
@@ -69,5 +69,5 @@ void ss(t_stacks *stacks)
} }
stacks->ss++; stacks->ss++;
if (stacks->print) if (stacks->print)
write(1, "ss\n", 3); secure_write(1, "ss\n", 3);
} }