-
Notifications
You must be signed in to change notification settings - Fork 0
/
vlrlist.c
executable file
·52 lines (43 loc) · 958 Bytes
/
vlrlist.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
/*
** vlrlist.c
** A list of vlrs.
*/
#include <stdio.h>
#include <stdlib.h>
#include "vlr.h"
#include "vlrlist.h"
#include "memory.h"
vlrlist vlrlist_constructor (void)
{
vlrlist newlist = (vlrlist) check_malloc (sizeof(vlrlist_struct));
newlist->list = NULL;
newlist->size = 0;
return (newlist);
}
void vlrlist_insert (vlrlist l, vlr rec)
{
l->size++;
l->list = (vlr *) check_realloc (l->list, sizeof(vlr) * l->size);
l->list[l->size-1] = rec;
}
void vlrlist_free (vlrlist l)
{
int i;
for (i = 0; i < l->size; i++) {
free(l->list[i]);
}
free(l->list);
l->size = 0;
}
int vlrlist_get_cur_length (vlrlist vlist, int tnode_id)
{
int vlist_cnt = 0;
while (vlist_cnt < vlist->size) {
if (vlist->list[vlist_cnt]->id == tnode_id) {
return (vlist->list[vlist_cnt]->cur);
}
vlist_cnt++;
}
fprintf(stderr, "vlist: getting current length of a non-existent tnode!\n");
exit (-1);
}