From c957257eee0eff569c91743ae6e3f80a00512e82 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Thu, 29 Feb 2024 10:29:12 +0100 Subject: [PATCH] Change return type of stack_push from void Previously the return type was void as handling any error was percieved as too annoying and action_push must have been void anyway. This change is done for future changes that may benefit from the information of error, while the return value is ignored in the functions that expect void. --- src/checker.h | 46 ++++++++++++++++++++-------------------- src/stack_manipulation.c | 7 +++--- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/checker.h b/src/checker.h index 52e74bf..2288d79 100644 --- a/src/checker.h +++ b/src/checker.h @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/24 12:13:51 by ljiriste #+# #+# */ -/* Updated: 2024/02/24 14:06:52 by ljiriste ### ########.fr */ +/* Updated: 2024/02/29 10:27:01 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -42,8 +42,8 @@ typedef struct s_command t_target target; } t_command; -void init_stack(t_stack *s); -void clean_up(t_stacks *s); +void init_stack(t_stack *s); +void clean_up(t_stacks *s); /* t_action action_push; t_action action_swap; @@ -51,27 +51,27 @@ t_action action_rotate; t_action action_reverse_rotate; */ -void action_push(t_stacks *s, t_target target); -void action_swap(t_stacks *s, t_target target); -void action_rotate(t_stacks *s, t_target target); -void action_reverse_rotate(t_stacks *s, t_target target); +void action_push(t_stacks *s, t_target target); +void action_swap(t_stacks *s, t_target target); +void action_rotate(t_stacks *s, t_target target); +void action_reverse_rotate(t_stacks *s, t_target target); -void print_push(t_stacks *s, t_target target); -void print_swap(t_stacks *s, t_target target); -void print_rotate(t_stacks *s, t_target target); -void print_reverse_rotate(t_stacks *s, t_target target); +void print_push(t_stacks *s, t_target target); +void print_swap(t_stacks *s, t_target target); +void print_rotate(t_stacks *s, t_target target); +void print_reverse_rotate(t_stacks *s, t_target target); -void stack_push(t_stack *s, int el); -void stack_swap(t_stack *s); -void stack_rotate(t_stack *s, int amount); -void stack_pop(t_stack *s); -int stack_top(t_stack *s); +t_arr_stat stack_push(t_stack *s, int el); +void stack_swap(t_stack *s); +void stack_rotate(t_stack *s, int amount); +void stack_pop(t_stack *s); +int stack_top(t_stack *s); -int is_sorted(t_stack *s); -int parse(int argc, char **argv, t_stack *s); -void prepare_stacks(t_stacks *s, size_t ind_a, size_t ind_b); -size_t cost(t_stacks *s, const size_t b_plus, const size_t a_plus); -size_t find_best(t_stacks *s, t_vec *target_a_indeces); -size_t find_target_ind(t_stack *stack, int val); -size_t find_minind(t_stack *s); +int is_sorted(t_stack *s); +int parse(int argc, char **argv, t_stack *s); +void prepare_stacks(t_stacks *s, size_t ind_a, size_t ind_b); +size_t cost(t_stacks *s, const size_t b_plus, const size_t a_plus); +size_t find_best(t_stacks *s, t_vec *target_a_indeces); +size_t find_target_ind(t_stack *stack, int val); +size_t find_minind(t_stack *s); #endif //CHECKER_H diff --git a/src/stack_manipulation.c b/src/stack_manipulation.c index 5003b62..dbc64b1 100644 --- a/src/stack_manipulation.c +++ b/src/stack_manipulation.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/24 11:48:47 by ljiriste #+# #+# */ -/* Updated: 2024/01/24 13:59:25 by ljiriste ### ########.fr */ +/* Updated: 2024/02/29 10:25:56 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,10 +46,9 @@ void stack_pop(t_stack *s) return ; } -void stack_push(t_stack *s, int el) +t_arr_stat stack_push(t_stack *s, int el) { - ft_vec_insert(&s->stack, &el, s->ind); - return ; + return (ft_vec_insert(&s->stack, &el, s->ind)); } void stack_swap(t_stack *s) -- 2.30.2