cpp: avoid a gazillion calls to memcpy/memmove
[m6w6/ext-psi] / src / parser.h
index 65c90121801e8a294e593f9cea31612c0610565f..7aef5f53f907b87fd0298ea9b11e9275ff6104ec 100644 (file)
@@ -46,21 +46,20 @@ struct psi_parser {
 
 struct psi_parser_input {
        size_t length;
-       char *file;
+       zend_string *file;
        unsigned lines;
        char buffer[1];
 };
 
-struct psi_parser_data {
-       enum {
-               PSI_PARSER_DATA_SELF,
-               PSI_PARSER_DATA_CPP
-       } type;
-       union {
-               struct psi_parser *parser;
-               struct psi_cpp *cpp;
-       } data;
-};
+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);