api refactoring
[m6w6/ext-psi] / src / types / decl_union.h
1 #ifndef _PSI_TYPES_DECL_UNION_H
2
3 typedef struct decl_union {
4 struct psi_token *token;
5 char *name;
6 decl_args *args;
7 size_t size;
8 size_t align;
9 } decl_union;
10
11 static inline decl_union *init_decl_union(const char *name, decl_args *args) {
12 decl_union *u = calloc(1, sizeof(*u));
13 u->name = strdup(name);
14 u->args = args;
15 return u;
16 }
17
18 static inline void free_decl_union(decl_union *u) {
19 if (u->token) {
20 free(u->token);
21 }
22 if (u->args) {
23 free_decl_args(u->args);
24 }
25 free(u->name);
26 free(u);
27 }
28
29 #endif