Skip to content

Commit 4e03ba4

Browse files
committed
Add GC support for ArrayObject
gc_024 test changes because the array that ArrayObject holds is now counted separately from the ArrayObject.
1 parent 4ea1d8a commit 4e03ba4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Zend/tests/gc_024.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ var_dump(gc_collect_cycles());
1313
echo "ok\n";
1414
?>
1515
--EXPECT--
16-
int(1)
16+
int(2)
1717
ok

ext/spl/spl_array.c

+10
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,15 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp) /* {{{ */
831831
}
832832
/* }}} */
833833

834+
static HashTable *spl_array_get_gc(zval *obj, zval **gc_data, int *gc_data_count) /* {{{ */
835+
{
836+
spl_array_object *intern = Z_SPLARRAY_P(obj);
837+
*gc_data = &intern->array;
838+
*gc_data_count = 1;
839+
return zend_std_get_properties(obj);
840+
}
841+
/* }}} */
842+
834843
static zval *spl_array_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */
835844
{
836845
spl_array_object *intern = Z_SPLARRAY_P(object);
@@ -1913,6 +1922,7 @@ PHP_MINIT_FUNCTION(spl_array)
19131922

19141923
spl_handler_ArrayObject.get_properties = spl_array_get_properties;
19151924
spl_handler_ArrayObject.get_debug_info = spl_array_get_debug_info;
1925+
spl_handler_ArrayObject.get_gc = spl_array_get_gc;
19161926
spl_handler_ArrayObject.read_property = spl_array_read_property;
19171927
spl_handler_ArrayObject.write_property = spl_array_write_property;
19181928
spl_handler_ArrayObject.get_property_ptr_ptr = spl_array_get_property_ptr_ptr;

0 commit comments

Comments
 (0)