diff options
Diffstat (limited to 'sorting.c')
| -rw-r--r-- | sorting.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -6,29 +6,34 @@ /* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/13 15:04:19 by dkaiser #+# #+# */ -/* Updated: 2024/04/13 15:17:26 by dkaiser ### ########.fr */ +/* Updated: 2024/04/13 17:43:18 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft/libft.h" #include "push_swap.h" + + static void stack_radixsort(t_list **stack_a, t_list **stack_b, t_list **cmds) { int bit; int max; int i; + int max_bits; bit = 0; - while (bit < 9) + max_bits = 9; + + while (bit < max_bits) { i = 0; max = ft_lstsize(*stack_a); while (i < max) { - if ((*(int *)(*stack_a)->content >> bit) % 2 == 0) + if (*stack_a && (*(int *)(*stack_a)->content >> bit) % 2 == 0) run_command(stack_a, stack_b, cmds, PB); - else + else if ((*stack_a)->next) run_command(stack_a, stack_b, cmds, RA); i++; } |
