-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathts.c
More file actions
57 lines (47 loc) · 804 Bytes
/
ts.c
File metadata and controls
57 lines (47 loc) · 804 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
52
53
54
55
56
57
#include "ts.h"
ts * tsymb = NULL;
static int mem_offset = 33;
void ts_ajouter_id(char *id, int size)
{
ts *new = malloc(sizeof(ts));
new->id = malloc(strlen(id)+1);
strcpy(new->id, id);
new->adr = mem_offset;
new->size = size;
mem_offset += size;
new->next = tsymb;
tsymb = new;
}
ts* ts_retrouver_id(char *id)
{
ts *t = tsymb;
while (t!=NULL){
if (strcmp(t->id, id)==0){
return t;
}
t = t->next;
}
return (ts*)0;
}
void ts_free_table()
{
ts *next, *t = tsymb;
while (t!=NULL){
next = t->next;
free(t->id);
free(t);
t = next;
}
}
void ts_print()
{
ts *t = tsymb;
if (t!=NULL){
printf("{%s : %d}", t->id, t->adr);
t = t->next;
}
while (t!=NULL){
printf("-->{%s : %d}", t->id, t->adr);
t = t->next;
}
}