fix leaks
[m6w6/ext-psi] / src / parser.h
index 261b2b9748e6b6c2f68a826578e0d9ec59c0fc70..7aef5f53f907b87fd0298ea9b11e9275ff6104ec 100644 (file)
@@ -51,6 +51,16 @@ struct psi_parser_input {
        char buffer[1];
 };
 
+static inline void psi_parser_input_free(struct psi_parser_input **I) {
+       if (*I) {
+               struct psi_parser_input *i = *I;
+
+               *I = NULL;
+               zend_string_release(i->file);
+               free(i);
+       }
+}
+
 struct psi_parser *psi_parser_init(struct psi_parser *P, psi_error_cb error, unsigned flags);
 struct psi_parser_input *psi_parser_open_file(struct psi_parser *P, const char *filename, bool report_errors);
 struct psi_parser_input *psi_parser_open_string(struct psi_parser *P, const char *string, size_t length);