api refactoring
[m6w6/ext-psi] / src / data.c
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #else
4 # include "php_config.h"
5 #endif
6
7 #include <string.h>
8
9 #include "data.h"
10
11 struct psi_data *psi_data_exchange(struct psi_data *dest, struct psi_data *src) {
12 if (!dest) {
13 dest = malloc(sizeof(*dest));
14 }
15 memcpy(dest, src, sizeof(*dest));
16 memset(src, 0, sizeof(*src));
17 return dest;
18 }
19
20 void psi_data_dtor(struct psi_data *data) {
21 if (data->consts) {
22 free_constants(data->consts);
23 }
24 if (data->defs) {
25 free_decl_typedefs(data->defs);
26 }
27 if (data->structs) {
28 free_decl_structs(data->structs);
29 }
30 if (data->unions) {
31 free_decl_unions(data->unions);
32 }
33 if (data->enums) {
34 free_decl_enums(data->enums);
35 }
36 if (data->decls) {
37 free_decls(data->decls);
38 }
39 if (data->impls) {
40 free_impls(data->impls);
41 }
42 free_decl_file(&data->psi.file);
43 }
44