src/xh_stack.c | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 9 | 10 | 90.0 |
branch | 1 | 2 | 50.0 |
condition | n/a | ||
subroutine | n/a | ||
pod | n/a | ||
total | 10 | 12 | 83.3 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | #include "xh_config.h" | ||||||
2 | #include "xh_core.h" | ||||||
3 | |||||||
4 | void | ||||||
5 | 41 | xh_stack_init(xh_stack_t *st, xh_uint_t nelts, size_t size) | |||||
6 | { | ||||||
7 | 41 | 50 | if ((st->elts = malloc(nelts * size)) == NULL) { | ||||
8 | 0 | croak("Memory allocation error"); | |||||
9 | } | ||||||
10 | 41 | st->size = size; | |||||
11 | 41 | st->nelts = nelts; | |||||
12 | 41 | st->top = 0; | |||||
13 | 41 | } | |||||
14 | |||||||
15 | void | ||||||
16 | 41 | xh_stack_destroy(xh_stack_t *st) | |||||
17 | { | ||||||
18 | 41 | free(st->elts); | |||||
19 | 41 | } |