-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinked_list_utils.c
More file actions
50 lines (44 loc) · 1.35 KB
/
Copy pathlinked_list_utils.c
File metadata and controls
50 lines (44 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* linked_list_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tbui-quo <tbui-quo@student.42wolfsburg.d> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/15 17:59:06 by tbui-quo #+# #+# */
/* Updated: 2023/09/15 18:00:47 by tbui-quo ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void stack_node_delete(t_stack **lst)
{
t_stack *temp;
if (*lst == NULL)
return ;
temp = *lst;
*lst = (*lst)->next;
free(temp);
}
void stack_clear(t_stack **stack)
{
while (*stack != NULL)
{
stack_node_delete(stack);
}
stack = NULL;
}
int lst_len(t_stack **lst)
{
t_stack *current;
int lst_len;
lst_len = 0;
current = *lst;
if (lst == NULL)
return (-1);
while (current != NULL)
{
current = current->next;
lst_len++;
}
return (lst_len);
}