Skip to content

Commit 339709e

Browse files
committed
Store zend_type ptr in associated types HT
1 parent 4e74519 commit 339709e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: Zend/zend_compile.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -9037,7 +9037,10 @@ static void zend_compile_use_trait(zend_ast *ast) /* {{{ */
90379037
}
90389038
/* }}} */
90399039

9040-
9040+
static void zend_associated_table_ht_dtor(zval *val) {
9041+
/* NO OP as we only use it to be able to refer and save pointers to zend_types */
9042+
// TODO do we actually want to store copies of types?
9043+
}
90419044

90429045
static void zend_compile_associated_type(zend_ast *ast) {
90439046
zend_class_entry *ce = CG(active_class_entry);
@@ -9054,16 +9057,15 @@ static void zend_compile_associated_type(zend_ast *ast) {
90549057
bool persistent = ce->type == ZEND_INTERNAL_CLASS;
90559058
if (associated_types == NULL) {
90569059
ce->associated_types = pemalloc(sizeof(HashTable), persistent);
9057-
zend_hash_init(ce->associated_types, 8, NULL, NULL, persistent);
9060+
zend_hash_init(ce->associated_types, 8, NULL, zend_associated_table_ht_dtor, persistent);
90589061
associated_types = ce->associated_types;
90599062
}
90609063
if (zend_hash_exists(associated_types, name)) {
90619064
zend_error_noreturn(E_COMPILE_ERROR,
90629065
"Cannot have two associated types with the same name \"%s\"", ZSTR_VAL(name));
90639066
}
9064-
zval tmp;
9065-
ZVAL_UNDEF(&tmp);
9066-
zend_hash_add_new(associated_types, name, &tmp);
9067+
9068+
zend_hash_add_new_ptr(associated_types, name, (void*) &zend_mixed_type);
90679069
}
90689070

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

0 commit comments

Comments
 (0)