Skip to content

Commit 2c1b5c4

Browse files
committed
Support GC for AppendIterator
This also requires adding GC support for ArrayIterator internal iterators.
1 parent afab9eb commit 2c1b5c4

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

ext/spl/spl_array.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,13 @@ static void spl_array_it_rewind(zend_object_iterator *iter) /* {{{ */
10791079
}
10801080
/* }}} */
10811081

1082+
static HashTable *spl_array_it_get_gc(zend_object_iterator *iter, zval **table, int *n)
1083+
{
1084+
*n = 1;
1085+
*table = &iter->data;
1086+
return NULL;
1087+
}
1088+
10821089
/* {{{ spl_array_set_array */
10831090
static void spl_array_set_array(zval *object, spl_array_object *intern, zval *array, zend_long ar_flags, int just_array) {
10841091
if (Z_TYPE_P(array) != IS_OBJECT && Z_TYPE_P(array) != IS_ARRAY) {
@@ -1135,7 +1142,7 @@ static const zend_object_iterator_funcs spl_array_it_funcs = {
11351142
spl_array_it_move_forward,
11361143
spl_array_it_rewind,
11371144
NULL,
1138-
NULL, /* get_gc */
1145+
spl_array_it_get_gc,
11391146
};
11401147

11411148
zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */

ext/spl/spl_iterators.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,11 +2140,10 @@ static HashTable *spl_dual_it_get_gc(zend_object *obj, zval **table, int *n)
21402140
/* Nothing to do */
21412141
break;
21422142
case DIT_AppendIterator:
2143-
// TODO
2144-
/*zend_get_gc_buffer_add_obj(gc_buffer, &object->u.append.iterator->std);
2143+
zend_get_gc_buffer_add_obj(gc_buffer, &object->u.append.iterator->std);
21452144
if (Z_TYPE(object->u.append.zarrayit) != IS_UNDEF) {
21462145
zend_get_gc_buffer_add_zval(gc_buffer, &object->u.append.zarrayit);
2147-
}*/
2146+
}
21482147
break;
21492148
case DIT_CachingIterator:
21502149
case DIT_RecursiveCachingIterator:

ext/spl/tests/bug65387.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ $it2[] = $it2;
4141
$it2->next();
4242

4343
// Append
44-
/* TODO
4544
$it = new ArrayIterator();
4645
$it2 = new AppendIterator();
4746
$it[] = $it2;
4847
$it2->append($it);
49-
*/
5048

5149
?>
5250
===DONE===

0 commit comments

Comments
 (0)