-
Notifications
You must be signed in to change notification settings - Fork 46
/
rct_mttlist.c
76 lines (59 loc) · 1.08 KB
/
rct_mttlist.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
63
64
65
66
67
68
69
70
71
72
73
74
#include "rct_core.h"
mttlist *mttlist_create(void)
{
mttlist *list;
list = rct_alloc(sizeof(*list));
if(list == NULL)
{
return NULL;
}
list->l = NULL;
list->lock_push = NULL;
list->lock_pop = NULL;
list->free = NULL;
list->length = NULL;
return list;
}
void mttlist_destroy(mttlist *list)
{
if(list == NULL)
{
return;
}
if(list->free)
{
list->free(list->l);
}
rct_free(list);
}
int mttlist_push(mttlist *list, void *value)
{
if(list == NULL || list->l == NULL
|| list->lock_push == NULL)
{
return RCT_ERROR;
}
return list->lock_push(list->l, value);
}
void *mttlist_pop(mttlist *list)
{
if(list == NULL || list->l == NULL
|| list->lock_pop == NULL)
{
return NULL;
}
return list->lock_pop(list->l);
}
int mttlist_empty(mttlist *list)
{
if(list == NULL || list->l == NULL
|| list->length == NULL)
{
return RCT_ERROR;
}
if(list->length(list->l) > 0)
{
return 0;
}
return 1;
}