api refactoring
[m6w6/ext-psi] / src / types / decl_union.h
diff --git a/src/types/decl_union.h b/src/types/decl_union.h
new file mode 100644 (file)
index 0000000..3bd031b
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef _PSI_TYPES_DECL_UNION_H
+
+typedef struct decl_union {
+       struct psi_token *token;
+       char *name;
+       decl_args *args;
+       size_t size;
+       size_t align;
+} decl_union;
+
+static inline decl_union *init_decl_union(const char *name, decl_args *args) {
+       decl_union *u = calloc(1, sizeof(*u));
+       u->name = strdup(name);
+       u->args = args;
+       return u;
+}
+
+static inline void free_decl_union(decl_union *u) {
+       if (u->token) {
+               free(u->token);
+       }
+       if (u->args) {
+               free_decl_args(u->args);
+       }
+       free(u->name);
+       free(u);
+}
+
+#endif