-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.c
More file actions
47 lines (43 loc) · 981 Bytes
/
list.c
File metadata and controls
47 lines (43 loc) · 981 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
//
// Created by JakoError on 2021/12/15.
//
#include "list.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
List newList(List next) {
List t = (List) malloc(sizeof(struct list));
if (t == NULL) {
printf("error in malloc list\n");
exit(0);
}
memset(t, 0, sizeof(struct list));
t->next = next;
t->element = createHashMap(NULL, NULL, 0);
return t;
}
VALUE_TYPE getVarValue(KEY_TYPE key) {
List r = range;
VALUE_TYPE result;
while (r != NULL) {
VALUE_TYPE*value = getValue(r->element, key);
if (value != NULL) {
result = *value;
break;
}
r = r->next;
}
if (r == NULL) {
printf("Error:use of undeclared identifier '%s'\n", key);
exit(0);
}
return result;
}
List exitRange(List list) {
if (list == NULL) return NULL;
List p = list;
list = list->next;
freeHashMap(p->element);
free(p);
return list;
}