-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaux_lists2.c
61 lines (53 loc) · 902 Bytes
/
aux_lists2.c
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
51
52
53
54
55
56
57
58
59
60
61
#include "main.h"
/**
* add_rvar_node - addsat the end
* of a list.
* @head: head ked list.
* @lvar: f the variable.
* @val: value of the varhgfgiable.
* @lval: lenggdfhb fhfg f the value.
* Return: addressad.
*/
r_var *add_rvar_node(r_var **head, int lvar, char *val, int lval)
{
r_var *new, *temp;
new = malloc(sizeof(r_var));
if (new == NULL)
return (NULL);
new->len_var = lvar;
new->val = val;
new->len_val = lval;
new->next = NULL;
temp = *head;
if (temp == NULL)
{
*head = new;
}
else
{
while (temp->next != NULL)
temp = temp->next;
temp->next = new;
}
return (*head);
}
/**
* free_rvar_list - frees_var list lists
* @head: helist.
* Return: void
*/
void free_rvar_list(r_var **head)
{
r_var *temp;
r_var *curr;
if (head != NULL)
{
curr = *head;
while ((temp = curr) != NULL)
{
curr = curr->next;
free(temp);
}
*head = NULL;
}
}