api refactoring
[m6w6/ext-psi] / src / types / decl_structs.h
1 #ifndef _PSI_TYPES_DECL_STRUCTS_H
2 #define _PSI_TYPES_DECL_STRUCTS_H
3
4 typedef struct decl_structs {
5 size_t count;
6 decl_struct **list;
7 } decl_structs;
8
9 static inline decl_structs *add_decl_struct(decl_structs *ss, decl_struct *s) {
10 if (!ss) {
11 ss = calloc(1, sizeof(*ss));
12 }
13 ss->list = realloc(ss->list, ++ss->count * sizeof(*ss->list));
14 ss->list[ss->count-1] = s;
15 return ss;
16 }
17
18 static inline void free_decl_structs(decl_structs *ss) {
19 size_t i;
20
21 for (i = 0; i < ss->count; ++i) {
22 free_decl_struct(ss->list[i]);
23 }
24 free(ss->list);
25 free(ss);
26 }
27
28 #endif