line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "stack.h" |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#include "buffer.h" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include |
6
|
|
|
|
|
|
|
#include |
7
|
|
|
|
|
|
|
#include |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
void |
10
|
14
|
|
|
|
|
|
hoedown_stack_init(hoedown_stack *st, size_t initial_size) |
11
|
|
|
|
|
|
|
{ |
12
|
14
|
50
|
|
|
|
|
assert(st); |
13
|
|
|
|
|
|
|
|
14
|
14
|
|
|
|
|
|
st->item = NULL; |
15
|
14
|
|
|
|
|
|
st->size = st->asize = 0; |
16
|
|
|
|
|
|
|
|
17
|
14
|
50
|
|
|
|
|
if (!initial_size) |
18
|
|
|
|
|
|
|
initial_size = 8; |
19
|
|
|
|
|
|
|
|
20
|
14
|
|
|
|
|
|
hoedown_stack_grow(st, initial_size); |
21
|
14
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
void |
24
|
0
|
|
|
|
|
|
hoedown_stack_uninit(hoedown_stack *st) |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
0
|
|
|
|
|
assert(st); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
free(st->item); |
29
|
0
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
void |
32
|
14
|
|
|
|
|
|
hoedown_stack_grow(hoedown_stack *st, size_t neosz) |
33
|
|
|
|
|
|
|
{ |
34
|
14
|
50
|
|
|
|
|
assert(st); |
35
|
|
|
|
|
|
|
|
36
|
14
|
50
|
|
|
|
|
if (st->asize >= neosz) |
37
|
|
|
|
|
|
|
return; |
38
|
|
|
|
|
|
|
|
39
|
14
|
|
|
|
|
|
st->item = hoedown_realloc(st->item, neosz * sizeof(void *)); |
40
|
14
|
|
|
|
|
|
memset(st->item + st->asize, 0x0, (neosz - st->asize) * sizeof(void *)); |
41
|
|
|
|
|
|
|
|
42
|
14
|
|
|
|
|
|
st->asize = neosz; |
43
|
|
|
|
|
|
|
|
44
|
14
|
50
|
|
|
|
|
if (st->size > neosz) |
45
|
0
|
|
|
|
|
|
st->size = neosz; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
void |
49
|
12
|
|
|
|
|
|
hoedown_stack_push(hoedown_stack *st, void *item) |
50
|
|
|
|
|
|
|
{ |
51
|
12
|
50
|
|
|
|
|
assert(st); |
52
|
|
|
|
|
|
|
|
53
|
12
|
50
|
|
|
|
|
if (st->size >= st->asize) |
54
|
0
|
|
|
|
|
|
hoedown_stack_grow(st, st->size * 2); |
55
|
|
|
|
|
|
|
|
56
|
12
|
|
|
|
|
|
st->item[st->size++] = item; |
57
|
12
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
void * |
60
|
0
|
|
|
|
|
|
hoedown_stack_pop(hoedown_stack *st) |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
0
|
|
|
|
|
assert(st); |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if (!st->size) |
65
|
|
|
|
|
|
|
return NULL; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return st->item[--st->size]; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
void * |
71
|
0
|
|
|
|
|
|
hoedown_stack_top(const hoedown_stack *st) |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
0
|
|
|
|
|
assert(st); |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
if (!st->size) |
76
|
|
|
|
|
|
|
return NULL; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return st->item[st->size - 1]; |
79
|
|
|
|
|
|
|
} |