basic support for builtins
[m6w6/ext-psi] / src / types / const.c
index 1a06e431eb3358492362b6cba62ab82449b7d9cb..b839d5f701897aa952fd2e7b6a24585942e63b05 100644 (file)
@@ -29,7 +29,7 @@
 struct psi_const *psi_const_init(struct psi_impl_type *type, zend_string *name,
                struct psi_impl_def_val *val)
 {
-       struct psi_const *c = calloc(1, sizeof(*c));
+       struct psi_const *c = pecalloc(1, sizeof(*c), 1);
 
        if (name->val[0] == '\\') {
                c->name = zend_string_init(&name->val[1], name->len-1, 1);
@@ -58,7 +58,9 @@ void psi_const_free(struct psi_const **constant_ptr)
 void psi_const_dump(int fd, struct psi_const *cnst)
 {
        dprintf(fd, "const ");
-       psi_impl_type_dump(fd, cnst->type);
+       if (cnst->type) {
+               psi_impl_type_dump(fd, cnst->type);
+       }
        dprintf(fd, " %s = ", cnst->name->val);
        psi_impl_def_val_dump(fd, cnst->val);
        dprintf(fd, ";");