api refactoring
[m6w6/ext-psi] / src / types / constant.h
1 #ifndef _PSI_TYPES_CONSTANT_H
2 #define _PSI_TYPES_CONSTANT_H
3
4 typedef struct constant {
5 const_type *type;
6 char *name;
7 impl_def_val *val;
8 } constant;
9
10 static inline constant *init_constant(const_type *type, const char *name, impl_def_val *val) {
11 constant *c = calloc(1, sizeof(*c));
12 c->type = type;
13 c->name = strdup(name);
14 c->val = val;
15 return c;
16 }
17
18 static inline void free_constant(constant *constant) {
19 free_const_type(constant->type);
20 free(constant->name);
21 free_impl_def_val(constant->val);
22 free(constant);
23 }
24
25 #endif