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