aboutsummaryrefslogtreecommitdiff
path: root/src/common/stack_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/stack_core.c')
-rw-r--r--src/common/stack_core.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/common/stack_core.c b/src/common/stack_core.c
index adab5b1..68f74ca 100644
--- a/src/common/stack_core.c
+++ b/src/common/stack_core.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/19 06:37:45 by cacharle #+# #+# */
-/* Updated: 2020/01/22 10:23:18 by cacharle ### ########.fr */
+/* Updated: 2021/09/10 10:32:43 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,11 +14,13 @@
t_stack *stack_new(int size)
{
- t_stack *stack;
+ t_stack *stack;
- if ((stack = (t_stack*)malloc(sizeof(t_stack))) == NULL)
+ stack = (t_stack *)malloc(sizeof(t_stack));
+ if (stack == NULL)
return (NULL);
- if ((stack->elements = (int*)malloc(sizeof(int) * size)) == NULL)
+ stack->elements = (int *)malloc(sizeof(int) * size);
+ if (stack->elements == NULL)
{
free(stack);
return (NULL);
@@ -28,12 +30,13 @@ t_stack *stack_new(int size)
return (stack);
}
-void stack_destroy(t_stack *stack)
+int stack_destroy(t_stack *stack)
{
if (stack == NULL)
- return ;
+ return (1);
free(stack->elements);
free(stack);
+ return (1);
}
void stack_push(t_stack *stack, int n)
@@ -49,7 +52,7 @@ void stack_pop(t_stack *stack)
stack->top--;
}
-int stack_peek(t_stack *stack)
+int stack_peek(t_stack *stack)
{
if (stack_empty(stack))
return (0);