Skip to content

Commit 0c82005

Browse files
committed
Store zend_type ptr in associated types HT
1 parent b09580e commit 0c82005

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Zend/zend_compile.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9028,7 +9028,10 @@ static void zend_compile_use_trait(zend_ast *ast) /* {{{ */
90289028
}
90299029
/* }}} */
90309030

9031-
9031+
static void zend_associated_table_ht_dtor(zval *val) {
9032+
/* NO OP as we only use it to be able to refer and save pointers to zend_types */
9033+
// TODO do we actually want to store copies of types?
9034+
}
90329035

90339036
static void zend_compile_associated_type(zend_ast *ast) {
90349037
zend_class_entry *ce = CG(active_class_entry);
@@ -9045,16 +9048,15 @@ static void zend_compile_associated_type(zend_ast *ast) {
90459048
bool persistent = ce->type == ZEND_INTERNAL_CLASS;
90469049
if (associated_types == NULL) {
90479050
ce->associated_types = pemalloc(sizeof(HashTable), persistent);
9048-
zend_hash_init(ce->associated_types, 8, NULL, NULL, persistent);
9051+
zend_hash_init(ce->associated_types, 8, NULL, zend_associated_table_ht_dtor, persistent);
90499052
associated_types = ce->associated_types;
90509053
}
90519054
if (zend_hash_exists(associated_types, name)) {
90529055
zend_error_noreturn(E_COMPILE_ERROR,
90539056
"Cannot have two associated types with the same name \"%s\"", ZSTR_VAL(name));
90549057
}
9055-
zval tmp;
9056-
ZVAL_UNDEF(&tmp);
9057-
zend_hash_add_new(associated_types, name, &tmp);
9058+
9059+
zend_hash_add_new_ptr(associated_types, name, (void*) &zend_mixed_type);
90589060
}
90599061

90609062
static void zend_compile_implements(zend_ast *ast) /* {{{ */

0 commit comments

Comments
 (0)