@@ -36,6 +36,7 @@ void zoi_with_current_dtor(zend_object_iterator *iter)
3636{
3737 zoi_with_current *zoiwc = (zoi_with_current*)iter;
3838 zval_ptr_dtor (&zoiwc->wrapping_obj );
39+ ZVAL_UNDEF (&zoiwc->wrapping_obj );
3940}
4041
4142U_CFUNC zend_result zoi_with_current_valid (zend_object_iterator *iter)
@@ -80,6 +81,14 @@ static void string_enum_current_move_forward(zend_object_iterator *iter)
8081 } // else we've reached the end of the enum, nothing more is required
8182}
8283
84+ HashTable *zoi_with_current_get_gc (zend_object_iterator *iter, zval **table, int *n)
85+ {
86+ zoi_with_current *zoiwc = reinterpret_cast <zoi_with_current*>(iter);
87+ *table = &zoiwc->wrapping_obj ;
88+ *n = 1 ;
89+ return nullptr ;
90+ }
91+
8392static void string_enum_rewind (zend_object_iterator *iter)
8493{
8594 zoi_with_current *zoi_iter = (zoi_with_current*)iter;
@@ -106,7 +115,6 @@ static void string_enum_rewind(zend_object_iterator *iter)
106115static void string_enum_destroy_it (zend_object_iterator *iter)
107116{
108117 delete (StringEnumeration*)Z_PTR (iter->data );
109- efree (iter);
110118}
111119
112120static const zend_object_iterator_funcs string_enum_object_iterator_funcs = {
@@ -117,7 +125,7 @@ static const zend_object_iterator_funcs string_enum_object_iterator_funcs = {
117125 string_enum_current_move_forward,
118126 string_enum_rewind,
119127 zoi_with_current_invalidate_current,
120- NULL , /* get_gc */
128+ zoi_with_current_get_gc,
121129};
122130
123131U_CFUNC void IntlIterator_from_StringEnumeration (StringEnumeration *se, zval *object)
@@ -135,18 +143,43 @@ U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *ob
135143 ZVAL_UNDEF (&((zoi_with_current*)ii->iterator )->current );
136144}
137145
138- static void IntlIterator_objects_free (zend_object *object)
146+ static void IntlIterator_objects_dtor (zend_object *object)
139147{
140148 IntlIterator_object *ii = php_intl_iterator_fetch_object (object);
141-
142149 if (ii->iterator ) {
143150 ((zoi_with_current*)ii->iterator )->destroy_it (ii->iterator );
151+ OBJ_RELEASE (&ii->iterator ->std );
152+ ii->iterator = NULL ;
144153 }
154+ }
155+
156+ static void IntlIterator_objects_free (zend_object *object)
157+ {
158+ IntlIterator_object *ii = php_intl_iterator_fetch_object (object);
159+
145160 intl_error_reset (INTLITERATOR_ERROR_P (ii));
146161
147162 zend_object_std_dtor (&ii->zo );
148163}
149164
165+ static HashTable *IntlIterator_object_get_gc (zend_object *obj, zval **table, int *n)
166+ {
167+ IntlIterator_object *ii = php_intl_iterator_fetch_object (obj);
168+ if (ii->iterator ) {
169+ zend_get_gc_buffer *gc_buffer = zend_get_gc_buffer_create ();
170+ zend_get_gc_buffer_add_obj (gc_buffer, &ii->iterator ->std );
171+ zend_get_gc_buffer_use (gc_buffer, table, n);
172+ } else {
173+ *table = nullptr ;
174+ *n = 0 ;
175+ }
176+ if (obj->properties == nullptr && obj->ce ->default_properties_count == 0 ) {
177+ return nullptr ;
178+ } else {
179+ return zend_std_get_properties (obj);
180+ }
181+ }
182+
150183static zend_object_iterator *IntlIterator_get_iterator (
151184 zend_class_entry *ce, zval *object, int by_ref)
152185{
@@ -263,7 +296,9 @@ U_CFUNC void intl_register_common_symbols(int module_number)
263296 sizeof IntlIterator_handlers);
264297 IntlIterator_handlers.offset = XtOffsetOf (IntlIterator_object, zo);
265298 IntlIterator_handlers.clone_obj = NULL ;
299+ IntlIterator_handlers.dtor_obj = IntlIterator_objects_dtor;
266300 IntlIterator_handlers.free_obj = IntlIterator_objects_free;
301+ IntlIterator_handlers.get_gc = IntlIterator_object_get_gc;
267302
268303 register_common_symbols (module_number);
269304}
0 commit comments