@@ -155,6 +155,13 @@ imemo_fields_trigger_wb_i(st_data_t key, st_data_t value, st_data_t arg)
155
155
return ST_CONTINUE ;
156
156
}
157
157
158
+ static int
159
+ imemo_fields_complex_wb_i (st_data_t key , st_data_t value , st_data_t arg )
160
+ {
161
+ RB_OBJ_WRITTEN ((VALUE )arg , Qundef , (VALUE )value );
162
+ return ST_CONTINUE ;
163
+ }
164
+
158
165
VALUE
159
166
rb_imemo_fields_new_complex_tbl (VALUE klass , st_table * tbl )
160
167
{
@@ -174,12 +181,19 @@ rb_imemo_fields_clone(VALUE fields_obj)
174
181
clone = rb_imemo_fields_new_complex (CLASS_OF (fields_obj ), 0 );
175
182
RBASIC_SET_SHAPE_ID (clone , shape_id );
176
183
st_table * src_table = rb_imemo_fields_complex_tbl (fields_obj );
177
- st_replace (rb_imemo_fields_complex_tbl (clone ), src_table );
184
+ st_table * dest_table = rb_imemo_fields_complex_tbl (clone );
185
+ st_replace (dest_table , src_table );
186
+ st_foreach (dest_table , imemo_fields_complex_wb_i , (st_data_t )clone );
178
187
}
179
188
else {
180
189
clone = imemo_fields_new (CLASS_OF (fields_obj ), RSHAPE_CAPACITY (shape_id ));
181
190
RBASIC_SET_SHAPE_ID (clone , shape_id );
182
- MEMCPY (rb_imemo_fields_ptr (clone ), rb_imemo_fields_ptr (fields_obj ), VALUE , RSHAPE_LEN (shape_id ));
191
+ VALUE * fields = rb_imemo_fields_ptr (clone );
192
+ attr_index_t fields_count = RSHAPE_LEN (shape_id );
193
+ MEMCPY (fields , rb_imemo_fields_ptr (fields_obj ), VALUE , fields_count );
194
+ for (attr_index_t i = 0 ; i < fields_count ; i ++ ) {
195
+ RB_OBJ_WRITTEN (clone , Qundef , fields [i ]);
196
+ }
183
197
}
184
198
185
199
return clone ;
0 commit comments