forked from thewhoo/ifj15
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ilist.c
62 lines (54 loc) · 1.08 KB
/
ilist.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
62
/*
* Course IFJ @ FIT VUT Brno, 2015
* IFJ15 Interpreter Project
*
* Authors:
* Lukas Osadsky - xosads00
* Pavol Plaskon - xplask00
* Pavel Pospisil - xpospi88
* Matej Postolka - xposto02
*
* Unless otherwise stated, all code is licensed under a
* GNU General Public License v2.0
*
*/
#include <stdlib.h>
#include "galloc.h"
#include "ilist.h"
Tins_list* list_init()
{
Tins_list* list = gmalloc(sizeof(Tins_list));
list->first = NULL;
list->act = NULL;
list->last = NULL;
return list;
}
void list_free(Tins_list *list)
{
TList_item *tmp;
while(list->first != NULL)
{
tmp = list->first;
list->first = list->first->next;
gfree(tmp);
}
gfree(list);
}
void list_insert(Tins_list *list, TList_item *item)
{
item->next = NULL;
if(list->first == NULL)
list->first = item;
else
list->last->next = item;
list->last = item;
}
void list_first(Tins_list *list)
{
list->act = list->first;
}
void list_next(Tins_list *list)
{
if(list->act != NULL)
list->act = list->act->next;
}