1 /* stack.h - simple stacking */
2 
3 #ifndef HOEDOWN_STACK_H
4 #define HOEDOWN_STACK_H
5 
6 #include <stddef.h>
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 
13 /*********
14  * TYPES *
15  *********/
16 
17 struct hoedown_stack {
18     void **item;
19     size_t size;
20     size_t asize;
21 };
22 typedef struct hoedown_stack hoedown_stack;
23 
24 
25 /*************
26  * FUNCTIONS *
27  *************/
28 
29 /* hoedown_stack_init: initialize a stack */
30 void hoedown_stack_init(hoedown_stack *st, size_t initial_size);
31 
32 /* hoedown_stack_uninit: free internal data of the stack */
33 void hoedown_stack_uninit(hoedown_stack *st);
34 
35 /* hoedown_stack_grow: increase the allocated size to the given value */
36 void hoedown_stack_grow(hoedown_stack *st, size_t neosz);
37 
38 /* hoedown_stack_push: push an item to the top of the stack */
39 void hoedown_stack_push(hoedown_stack *st, void *item);
40 
41 /* hoedown_stack_pop: retrieve and remove the item at the top of the stack */
42 void *hoedown_stack_pop(hoedown_stack *st);
43 
44 /* hoedown_stack_top: retrieve the item at the top of the stack */
45 void *hoedown_stack_top(const hoedown_stack *st);
46 
47 
48 #ifdef __cplusplus
49 }
50 #endif
51 
52 #endif /** HOEDOWN_STACK_H **/
53