X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_message_object.c;h=edc18a0499d549d1a7c026afd1e25c51e36aef2c;hb=438d27e988e114136d931c6e3586ce3ee38e2ad2;hp=eb35995bed76a3d7eadcc7ba21aabbf78da06681;hpb=73508c8e9957ba07de65e41342f74fd49a8ce13a;p=m6w6%2Fext-http diff --git a/http_message_object.c b/http_message_object.c index eb35995..edc18a0 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -350,7 +350,8 @@ zend_object_value _http_message_object_new_ex(zend_class_entry *ce, http_message } ALLOC_HASHTABLE(OBJ_PROP(o)); - zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); ov.handle = putObject(http_message_object, o); ov.handlers = &http_message_object_handlers; @@ -360,18 +361,20 @@ zend_object_value _http_message_object_new_ex(zend_class_entry *ce, http_message zend_object_value _http_message_object_clone_obj(zval *this_ptr TSRMLS_DC) { - getObject(http_message_object, obj); - return http_message_object_new_ex(Z_OBJCE_P(this_ptr), http_message_dup(obj->message), NULL); + zend_object_value new_ov; + http_message_object *new_obj = NULL; + getObject(http_message_object, old_obj); + + new_ov = http_message_object_new_ex(old_obj->zo.ce, http_message_dup(old_obj->message), &new_obj); + zend_objects_clone_members(&new_obj->zo, new_ov, &old_obj->zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC); + + return new_ov; } void _http_message_object_free(zend_object *object TSRMLS_DC) { http_message_object *o = (http_message_object *) object; - if (OBJ_PROP(o)) { - zend_hash_destroy(OBJ_PROP(o)); - FREE_HASHTABLE(OBJ_PROP(o)); - } if (o->message) { http_message_dtor(o->message); efree(o->message); @@ -384,7 +387,7 @@ void _http_message_object_free(zend_object *object TSRMLS_DC) p.value.obj = o->parent; zend_objects_store_del_ref(&p TSRMLS_CC); } - efree(o); + freeObject(o); } static zval *_http_message_object_read_prop(zval *object, zval *member, int type TSRMLS_DC)