Debian Codegraph @

src/xh_stack.c

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