ffi: improve support for functions returning arrays
[m6w6/ext-psi] / src / validate.c
index 1d55b13f26ca8a5b4c4d6e11ad7686b381017ec8..2dfc3d46103b7d4a96be8069f19cdcf467670f3e 100644 (file)
@@ -203,17 +203,20 @@ bool psi_validate(struct psi_validate_scope *scope,
                }
 
                /* nothing changed; bail out */
-               if (count_all && (dst->flags & PSI_SILENT) && !(flags & PSI_SILENT)) {
-                       /* one last error-spitting round, if not explicitly suppressed */
-                       dst->flags ^= PSI_SILENT;
-                       check_count = ~0;
+               if (count_all) {
+                       src->errors += count_all;
 
-                       PSI_DEBUG_PRINT(dst, "PSI: validation bail out with %zu"
-                                       " type checks remaining, errors follow\n", count_all);
-                       continue;
+                       if ((dst->flags & PSI_SILENT) && !(flags & PSI_SILENT)) {
+                               /* one last error-spitting round, if not explicitly suppressed */
+                               dst->flags ^= PSI_SILENT;
+                               check_count = ~0;
+
+                               PSI_DEBUG_PRINT(dst, "PSI: validation bail out with %zu"
+                                               " type checks remaining, errors follow\n", count_all);
+                               continue;
+                       }
                }
 
-               src->errors += count_all;
                break;
        }
 
@@ -223,5 +226,30 @@ bool psi_validate(struct psi_validate_scope *scope,
        psi_validate_list(scope, dst, &consts, psi_validate_const);
        psi_validate_list(scope, dst, &impls, psi_validate_impl);
 
+       if (types.cur != types.src) {
+               psi_plist_free(types.cur);
+       }
+       if (structs.cur != structs.src) {
+               psi_plist_free(structs.cur);
+       }
+       if (unions.cur != unions.src) {
+               psi_plist_free(unions.cur);
+       }
+       if (enums.cur != enums.src) {
+               psi_plist_free(enums.cur);
+       }
+       if (vars.cur != vars.src) {
+               psi_plist_free(vars.cur);
+       }
+       if (decls.cur != decls.src) {
+               psi_plist_free(decls.cur);
+       }
+       if (consts.cur != consts.src) {
+               psi_plist_free(consts.cur);
+       }
+       if (impls.cur != impls.src) {
+               psi_plist_free(impls.cur);
+       }
+
        return true;
 }