-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfree_str.c
50 lines (46 loc) · 1.12 KB
/
free_str.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
#include "free_str.h"
#include "parser.h"
#include "hash_map.h"
#include <stdlib.h>
/**
* This will free all the commands in the
* list
*/
void freeCommandList(CommandList * list) {
if (list != NULL) {
if (list->frstCmd != NULL) {
Command * curr = list->frstCmd;
for (int i=0; i<list->len; i++) {
free(curr->argv);
curr = curr->nxtCmd;
}
//if (curr != NULL) {
// fprintf(stderr, "the next command is not null! There is AN ISSUE WITH THE COMMANDS, MAYBE THE LENGTH\n");
// exit(-1);
//}
}
free(list);
}
}
void freeBuildSpec(BuildSpec * spec) {
if (spec != NULL) {
freeCommandList(spec->cmds);
free(spec->deps);
free(spec);
}
}
void freeNode(BuildSpecNode * node) {
if (node != NULL) {
freeBuildSpec(node->data);
free(node);
}
}
void freeHashMap(DAG_map * map) {
if (map == NULL) {
fprintf(stderr, "Map is null, ending program...\n");
}
int i;
for(i=0; i<map->size;i++) {
freeNode(map->map[i]);
}
}