@@ -36,6 +36,7 @@ void zoi_with_current_dtor(zend_object_iterator *iter)
36
36
{
37
37
zoi_with_current *zoiwc = (zoi_with_current*)iter;
38
38
zval_ptr_dtor (&zoiwc->wrapping_obj );
39
+ ZVAL_UNDEF (&zoiwc->wrapping_obj );
39
40
}
40
41
41
42
U_CFUNC int zoi_with_current_valid (zend_object_iterator *iter)
@@ -80,6 +81,14 @@ static void string_enum_current_move_forward(zend_object_iterator *iter)
80
81
} // else we've reached the end of the enum, nothing more is required
81
82
}
82
83
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
+
83
92
static void string_enum_rewind (zend_object_iterator *iter)
84
93
{
85
94
zoi_with_current *zoi_iter = (zoi_with_current*)iter;
@@ -106,7 +115,6 @@ static void string_enum_rewind(zend_object_iterator *iter)
106
115
static void string_enum_destroy_it (zend_object_iterator *iter)
107
116
{
108
117
delete (StringEnumeration*)Z_PTR (iter->data );
109
- efree (iter);
110
118
}
111
119
112
120
static 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 = {
117
125
string_enum_current_move_forward,
118
126
string_enum_rewind,
119
127
zoi_with_current_invalidate_current,
120
- NULL , /* get_gc */
128
+ zoi_with_current_get_gc,
121
129
};
122
130
123
131
U_CFUNC void IntlIterator_from_StringEnumeration (StringEnumeration *se, zval *object)
@@ -135,18 +143,43 @@ U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *ob
135
143
ZVAL_UNDEF (&((zoi_with_current*)ii->iterator )->current );
136
144
}
137
145
138
- static void IntlIterator_objects_free (zend_object *object)
146
+ static void IntlIterator_objects_dtor (zend_object *object)
139
147
{
140
148
IntlIterator_object *ii = php_intl_iterator_fetch_object (object);
141
-
142
149
if (ii->iterator ) {
143
150
((zoi_with_current*)ii->iterator )->destroy_it (ii->iterator );
151
+ OBJ_RELEASE (&ii->iterator ->std );
152
+ ii->iterator = NULL ;
144
153
}
154
+ }
155
+
156
+ static void IntlIterator_objects_free (zend_object *object)
157
+ {
158
+ IntlIterator_object *ii = php_intl_iterator_fetch_object (object);
159
+
145
160
intl_error_reset (INTLITERATOR_ERROR_P (ii));
146
161
147
162
zend_object_std_dtor (&ii->zo );
148
163
}
149
164
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
+
150
183
static zend_object_iterator *IntlIterator_get_iterator (
151
184
zend_class_entry *ce, zval *object, int by_ref)
152
185
{
@@ -273,7 +306,9 @@ U_CFUNC void intl_register_common_symbols(int module_number)
273
306
sizeof IntlIterator_handlers);
274
307
IntlIterator_handlers.offset = XtOffsetOf (IntlIterator_object, zo);
275
308
IntlIterator_handlers.clone_obj = NULL ;
309
+ IntlIterator_handlers.dtor_obj = IntlIterator_objects_dtor;
276
310
IntlIterator_handlers.free_obj = IntlIterator_objects_free;
311
+ IntlIterator_handlers.get_gc = IntlIterator_object_get_gc;
277
312
278
313
register_common_symbols (module_number);
279
314
}
0 commit comments