fix gdbinit; postprocessing macros
[m6w6/ext-psi] / src / types / free_exp.c
index 57ede26295cc969d460516362bc9a9ebe0726597..1a29cd2497ffe42236a3d6528ee63b10deb6ff35 100644 (file)
 #include "data.h"
 #include "call.h"
 
-struct psi_free_exp *psi_free_exp_init(const char *func, struct psi_plist *vars)
+struct psi_free_exp *psi_free_exp_init(zend_string *func, struct psi_plist *vars)
 {
-       struct psi_free_exp *f = calloc(1, sizeof(*f));
-       f->func = strdup(func);
+       struct psi_free_exp *f = pecalloc(1, sizeof(*f), 1);
+       f->func = zend_string_copy(func);
        f->vars = vars;
        return f;
 }
@@ -41,10 +41,8 @@ void psi_free_exp_free(struct psi_free_exp **f_ptr)
                struct psi_free_exp *f = *f_ptr;
 
                *f_ptr = NULL;
-               if (f->token) {
-                       free(f->token);
-               }
-               free(f->func);
+               psi_token_free(&f->token);
+               zend_string_release(f->func);
                psi_plist_free(f->vars);
                if (f->let) {
                        free(f->let);
@@ -53,19 +51,19 @@ void psi_free_exp_free(struct psi_free_exp **f_ptr)
        }
 }
 
-void psi_free_exp_dump(int fd, struct psi_free_exp *call)
+void psi_free_exp_dump(struct psi_dump *dump, struct psi_free_exp *call)
 {
        size_t l = 0, c = psi_plist_count(call->vars);
        struct psi_decl_var *fvar;
 
-       dprintf(fd, "%s(", call->func);
+       PSI_DUMP(dump, "%s(", call->func->val);
        while (psi_plist_get(call->vars, l++, &fvar)) {
-               psi_decl_var_dump(fd, fvar);
+               psi_decl_var_dump(dump, fvar);
                if (l < c) {
-                       dprintf(fd, ", ");
+                       PSI_DUMP(dump, ", ");
                }
        }
-       dprintf(fd, ")");
+       PSI_DUMP(dump, ")");
 }
 
 static inline struct psi_decl *locate_free_decl(struct psi_plist *decls,
@@ -76,7 +74,7 @@ static inline struct psi_decl *locate_free_decl(struct psi_plist *decls,
                struct psi_decl *decl;
 
                while (psi_plist_get(decls, i++, &decl)) {
-                       if (!strcmp(decl->func->var->name, f->func)) {
+                       if (zend_string_equals(decl->func->var->name, f->func)) {
                                return f->decl = decl;
                        }
                }
@@ -86,7 +84,7 @@ static inline struct psi_decl *locate_free_decl(struct psi_plist *decls,
 }
 
 bool psi_free_exp_validate(struct psi_data *data, struct psi_free_exp *exp,
-               struct psi_impl *impl)
+               struct psi_validate_scope *scope)
 {
        size_t i;
        struct psi_decl_var *free_var;
@@ -95,22 +93,23 @@ bool psi_free_exp_validate(struct psi_data *data, struct psi_free_exp *exp,
        if (!locate_free_decl(data->decls, exp)) {
                data->error(data, exp->token, PSI_WARNING,
                                "Missing declaration '%s' in `free` statement"
-                               " of implementation '%s'", exp->func, impl->func->name);
+                               " of implementation '%s'", exp->func->val,
+                               scope->impl->func->name->val);
                return false;
        }
 
        /* now check for known vars */
-       exp->let = calloc(psi_plist_count(exp->vars), sizeof(*exp->let));
+       exp->let = pecalloc(psi_plist_count(exp->vars), sizeof(*exp->let), 1);
        for (i = 0; psi_plist_get(exp->vars, i, &free_var); ++i) {
-               if (!psi_impl_get_decl_arg(impl, free_var)) {
+               if (!psi_impl_get_decl_arg(scope->impl, free_var)) {
                        data->error(data, free_var->token, PSI_WARNING,
                                        "Unknown variable '%s' of `free` statement"
                                        " of implementation '%s'",
-                                       free_var->name, impl->func->name);
+                                       free_var->name->val, scope->impl->func->name->val);
                        return false;
                }
 
-               exp->let[i] = psi_impl_get_let(impl, free_var);
+               exp->let[i] = psi_impl_get_let(scope->impl, free_var);
                assert(exp->let[i]);
        }