| 1 | #include "xh_config.h" | ||||||||||
| 2 | #include "xh_core.h" | ||||||||||
| 3 | |||||||||||
| 4 | void | ||||||||||
| 5 | 56 | xh_stack_init(xh_stack_t *st, xh_uint_t nelts, size_t size) | |||||||||
| 6 | { | ||||||||||
| 7 | 56 | ▶ | if ((st->elts = malloc(nelts * size)) == NULL) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 8 | 0 | croak("Memory allocation error"); | |||||||||
| 9 | } | ||||||||||
| 10 | 56 | st->size = size; | |||||||||
| 11 | 56 | st->nelts = nelts; | |||||||||
| 12 | 56 | st->top = 0; | |||||||||
| 13 | 56 | } | |||||||||
| 14 | |||||||||||
| 15 | void | ||||||||||
| 16 | 56 | xh_stack_destroy(xh_stack_t *st) | |||||||||
| 17 | { | ||||||||||
| 18 | 56 | free(st->elts); | |||||||||
| 19 | 56 | } | |||||||||