improve/fix build
[m6w6/ext-psi] / src / context.c
index 218da24abb541a0a45d012650f51fa46550822e0..5585dfef4cca8bf6aee358ff5909963e5600c7c1 100644 (file)
@@ -2,6 +2,8 @@
 # include "config.h"
 #endif
 
+#include "php_psi_stdinc.h"
+
 #include "php.h"
 
 #ifdef HAVE_DIRENT_H
@@ -184,7 +186,7 @@ void PSI_ContextBuild(PSI_Context *C, const char *paths)
 {
        int i, n;
        char *sep = NULL, *cpy = strdup(paths), *ptr = cpy;
-       struct dirent **entries = NULL;
+       struct dirent **entries;
 
        do {
                sep = strchr(ptr, ':');
@@ -193,6 +195,7 @@ void PSI_ContextBuild(PSI_Context *C, const char *paths)
                        *sep = 0;
                }
 
+               entries = NULL;
                n = php_scandir(ptr, &entries, psi_select_dirent, alphasort);
 
                if (n > 0) {
@@ -341,6 +344,12 @@ void PSI_ContextDtor(PSI_Context *C)
                }
                free(C->structs);
        }
+       if (C->unions) {
+               if (C->unions->list) {
+                       free(C->unions->list);
+               }
+               free(C->unions);
+       }
        if (C->enums) {
                if (C->enums->list) {
                        free(C->enums->list);