-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_freeops.c
More file actions
51 lines (49 loc) · 871 Bytes
/
_freeops.c
File metadata and controls
51 lines (49 loc) · 871 Bytes
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
#include "holberton.h"
/**
*free_all - frees all of the variables used
*@line: the original line entered by user
*@newline: line truncated to remove new line char
*@tokenarray: array of token strings
*
*Return: void
*/
void free_all(char *line, char *newline, char **tokenarray)
{
free_tokens(tokenarray);
free(line);
free(newline);
free(tokenarray);
}
/**
*free_list - frees a list_t list
*@head: head of the linked list
*
*Return: void
*/
void free_list(path_t *head)
{
path_t *nextnode;
while (head != NULL)
{
nextnode = head->next;
free(head->directory);
free(head);
head = nextnode;
}
}
/**
*free_tokens - frees the tokens in the tokenarray
*@tokenarray: array of tokens
*
*Return: void
*/
void free_tokens(char **tokenarray)
{
int i = 0;
while (tokenarray[i] != NULL)
{
free(tokenarray[i]);
i++;
}
free(tokenarray[i]);
}