Skip to content

Commit

Permalink
Add GC support for ArrayObject
Browse files Browse the repository at this point in the history
gc_024 test changes because the array that ArrayObject holds is
now counted separately from the ArrayObject.
  • Loading branch information
nikic committed May 20, 2015
1 parent 4ea1d8a commit 4e03ba4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Zend/tests/gc_024.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ var_dump(gc_collect_cycles());
echo "ok\n";
?>
--EXPECT--
int(1)
int(2)
ok
10 changes: 10 additions & 0 deletions ext/spl/spl_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,15 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp) /* {{{ */
}
/* }}} */

static HashTable *spl_array_get_gc(zval *obj, zval **gc_data, int *gc_data_count) /* {{{ */
{
spl_array_object *intern = Z_SPLARRAY_P(obj);
*gc_data = &intern->array;
*gc_data_count = 1;
return zend_std_get_properties(obj);
}
/* }}} */

static zval *spl_array_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */
{
spl_array_object *intern = Z_SPLARRAY_P(object);
Expand Down Expand Up @@ -1913,6 +1922,7 @@ PHP_MINIT_FUNCTION(spl_array)

spl_handler_ArrayObject.get_properties = spl_array_get_properties;
spl_handler_ArrayObject.get_debug_info = spl_array_get_debug_info;
spl_handler_ArrayObject.get_gc = spl_array_get_gc;
spl_handler_ArrayObject.read_property = spl_array_read_property;
spl_handler_ArrayObject.write_property = spl_array_write_property;
spl_handler_ArrayObject.get_property_ptr_ptr = spl_array_get_property_ptr_ptr;
Expand Down

0 comments on commit 4e03ba4

Please sign in to comment.