/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* push.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/13 12:08:03 by rparodi #+# #+# */ /* Updated: 2024/03/06 11:55:32 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "../includes/push_swap.h" static int push(t_list **stack_to, t_list **stack_from) { t_list *tmp; t_list *head_to; t_list *head_from; if (ft_lstsize(*stack_from) == 0) return (-1); head_to = *stack_to; head_from = *stack_from; tmp = head_from; head_from = head_from->next; *stack_from = head_from; if (!head_to) { head_to = tmp; head_to->next = NULL; *stack_to = head_to; } else { tmp->next = head_to; *stack_to = tmp; } return (0); } int pa(t_list **stack_a, t_list **stack_b) { if (push(stack_a, stack_b) == -1) return (-1); write(1, "pa\n", 3); return (0); } int pb(t_list **stack_a, t_list **stack_b) { if (push(stack_b, stack_a) == -1) return (-1); write(1, "pb\n", 3); return (0); }